Skip to content

Commit

Permalink
Port code to new API.
Browse files Browse the repository at this point in the history
Signed-off-by: Marcin Owsiany <porridge@redhat.com>
  • Loading branch information
porridge committed Nov 29, 2023
1 parent d3eac9a commit e7e5965
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/test/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (h *Harness) addNodeCaches(dockerClient testutils.DockerClient, kindCfg *ki
}

for index := range kindCfg.Nodes {
volume, err := dockerClient.VolumeCreate(context.TODO(), volumetypes.VolumeCreateBody{
volume, err := dockerClient.VolumeCreate(context.TODO(), volumetypes.CreateOptions{
Driver: "local",
Name: fmt.Sprintf("%s-%d", h.TestSuite.KINDContext, index),
})
Expand Down
7 changes: 3 additions & 4 deletions pkg/test/harness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"
"testing"

dockertypes "github.com/docker/docker/api/types"
volumetypes "github.com/docker/docker/api/types/volume"
"github.com/stretchr/testify/assert"
kindConfig "sigs.k8s.io/kind/pkg/apis/config/v1alpha4"
Expand Down Expand Up @@ -42,9 +41,9 @@ func newDockerMock() *dockerMock {
}
}

func (d *dockerMock) VolumeCreate(_ context.Context, body volumetypes.VolumeCreateBody) (dockertypes.Volume, error) {
return dockertypes.Volume{
Mountpoint: fmt.Sprintf("/var/lib/docker/data/%s", body.Name),
func (d *dockerMock) VolumeCreate(_ context.Context, options volumetypes.CreateOptions) (volumetypes.Volume, error) {
return volumetypes.Volume{
Mountpoint: fmt.Sprintf("/var/lib/docker/data/%s", options.Name),
}, nil
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/test/utils/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import (
"context"
"io"

dockertypes "github.com/docker/docker/api/types"
volumetypes "github.com/docker/docker/api/types/volume"
)

// DockerClient is a wrapper interface for the Docker library to support unit testing.
type DockerClient interface {
NegotiateAPIVersion(context.Context)
VolumeCreate(context.Context, volumetypes.VolumeCreateBody) (dockertypes.Volume, error)
VolumeCreate(context.Context, volumetypes.CreateOptions) (volumetypes.Volume, error)
ImageSave(context.Context, []string) (io.ReadCloser, error)
}

0 comments on commit e7e5965

Please # to comment.