Skip to content

Commit

Permalink
Bump github.com/docker/docker in /flytectl (#5363)
Browse files Browse the repository at this point in the history
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 20.10.7+incompatible to 24.0.9+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](moby/moby@v20.10.7...v24.0.9)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
...

- Some types changed packages and some structs had new fields added.
  Move those around regenerate mocks with `make generate`

Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: ddl-ebrown <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
ddl-ebrown and dependabot[bot] authored May 15, 2024
1 parent 2f38d65 commit 7b82397
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 679 deletions.
8 changes: 3 additions & 5 deletions flytectl/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ require (
github.com/awalterschulze/gographviz v2.0.3+incompatible
github.com/charmbracelet/bubbles v0.18.0
github.com/charmbracelet/bubbletea v0.25.0
github.com/charmbracelet/lipgloss v0.10.0
github.com/disiqueira/gotree v1.0.0
github.com/docker/docker v20.10.7+incompatible
github.com/docker/docker v24.0.9+incompatible
github.com/docker/go-connections v0.4.0
github.com/enescakir/emoji v1.0.0
github.com/flyteorg/flyte/flyteidl v0.0.0-00010101000000-000000000000
Expand Down Expand Up @@ -60,17 +61,13 @@ require (
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/Microsoft/hcsshim v0.9.10 // indirect
github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496 // indirect
github.com/aws/aws-sdk-go v1.44.2 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/charmbracelet/lipgloss v0.10.0 // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
github.com/containerd/containerd v1.6.26 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/coocood/freecache v1.1.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/danieljoos/wincred v1.1.0 // indirect
Expand Down Expand Up @@ -172,6 +169,7 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gotest.tools/v3 v3.5.0 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect
Expand Down
611 changes: 2 additions & 609 deletions flytectl/go.sum

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions flytectl/pkg/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@ import (

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/volume"
"github.com/docker/docker/client"
specs "github.com/opencontainers/image-spec/specs-go/v1"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)

//go:generate mockery -all -case=underscore

type Docker interface {
ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.ContainerCreateCreatedBody, error)
ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error)
ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error
ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error)
ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.ContainerWaitOKBody, <-chan error)
ContainerWait(ctx context.Context, container string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)
ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error)
ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error
ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)
Expand All @@ -29,8 +28,8 @@ type Docker interface {
ImageList(ctx context.Context, listOption types.ImageListOptions) ([]types.ImageSummary, error)
ContainerStatPath(ctx context.Context, containerID, path string) (types.ContainerPathStat, error)
CopyFromContainer(ctx context.Context, containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
VolumeCreate(ctx context.Context, options volume.VolumeCreateBody) (types.Volume, error)
VolumeList(ctx context.Context, filter filters.Args) (volume.VolumeListOKBody, error)
VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error)
VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error)
VolumeRemove(ctx context.Context, volumeID string, force bool) error
}

Expand Down
13 changes: 8 additions & 5 deletions flytectl/pkg/docker/docker_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,21 +373,24 @@ func PrintCreateVolume(name string) {

func GetOrCreateVolume(
ctx context.Context, cli Docker, volumeName string, dryRun bool,
) (*types.Volume, error) {
) (*volume.Volume, error) {
if dryRun {
PrintCreateVolume(volumeName)
return nil, nil
}

resp, err := cli.VolumeList(ctx, filters.NewArgs(
filters.KeyValuePair{Key: "name", Value: fmt.Sprintf("^%s$", volumeName)},
))
lo := volume.ListOptions{
Filters: filters.NewArgs(
filters.KeyValuePair{Key: "name", Value: fmt.Sprintf("^%s$", volumeName)},
),
}
resp, err := cli.VolumeList(ctx, lo)
if err != nil {
return nil, err
}
switch len(resp.Volumes) {
case 0:
v, err := cli.VolumeCreate(ctx, volume.VolumeCreateBody{Name: volumeName})
v, err := cli.VolumeCreate(ctx, volume.CreateOptions{Name: volumeName})
if err != nil {
return nil, err
}
Expand Down
22 changes: 11 additions & 11 deletions flytectl/pkg/docker/docker_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func TestStartContainer(t *testing.T) {
PortBindings: p2,
Privileged: true,
ExtraHosts: ExtraHosts,
}, nil, nil, mock.Anything).Return(container.ContainerCreateCreatedBody{
}, nil, nil, mock.Anything).Return(container.CreateResponse{
ID: "Hello",
}, nil)
mockDocker.OnContainerStart(ctx, "Hello", types.ContainerStartOptions{}).Return(nil)
Expand Down Expand Up @@ -227,7 +227,7 @@ func TestStartContainer(t *testing.T) {
PortBindings: p2,
Privileged: true,
ExtraHosts: ExtraHosts,
}, nil, nil, mock.Anything).Return(container.ContainerCreateCreatedBody{
}, nil, nil, mock.Anything).Return(container.CreateResponse{
ID: "Hello",
}, nil)
mockDocker.OnContainerStart(ctx, "Hello", types.ContainerStartOptions{}).Return(nil)
Expand All @@ -254,7 +254,7 @@ func TestStartContainer(t *testing.T) {
PortBindings: p2,
Privileged: true,
ExtraHosts: ExtraHosts,
}, nil, nil, mock.Anything).Return(container.ContainerCreateCreatedBody{
}, nil, nil, mock.Anything).Return(container.CreateResponse{
ID: "",
}, fmt.Errorf("error"))
mockDocker.OnContainerStart(ctx, "Hello", types.ContainerStartOptions{}).Return(nil)
Expand All @@ -280,7 +280,7 @@ func TestStartContainer(t *testing.T) {
PortBindings: p2,
Privileged: true,
ExtraHosts: ExtraHosts,
}, nil, nil, mock.Anything).Return(container.ContainerCreateCreatedBody{
}, nil, nil, mock.Anything).Return(container.CreateResponse{
ID: "Hello",
}, nil)
mockDocker.OnContainerStart(ctx, "Hello", types.ContainerStartOptions{}).Return(fmt.Errorf("error"))
Expand Down Expand Up @@ -415,20 +415,20 @@ func TestGetOrCreateVolume(t *testing.T) {
t.Run("VolumeExists", func(t *testing.T) {
ctx := context.Background()
mockDocker := &mocks.Docker{}
expected := &types.Volume{Name: "test"}
expected := &volume.Volume{Name: "test"}

mockDocker.OnVolumeList(ctx, filters.NewArgs(filters.KeyValuePair{Key: "name", Value: "^test$"})).Return(volume.VolumeListOKBody{Volumes: []*types.Volume{expected}}, nil)
mockDocker.OnVolumeList(ctx, volume.ListOptions{Filters: filters.NewArgs(filters.KeyValuePair{Key: "name", Value: "^test$"})}).Return(volume.ListResponse{Volumes: []*volume.Volume{expected}}, nil)
actual, err := GetOrCreateVolume(ctx, mockDocker, "test", false)
assert.Equal(t, expected, actual, "volumes should match")
assert.Nil(t, err)
})
t.Run("VolumeDoesNotExist", func(t *testing.T) {
ctx := context.Background()
mockDocker := &mocks.Docker{}
expected := types.Volume{Name: "test"}
expected := volume.Volume{Name: "test"}

mockDocker.OnVolumeList(ctx, filters.NewArgs(filters.KeyValuePair{Key: "name", Value: "^test$"})).Return(volume.VolumeListOKBody{Volumes: []*types.Volume{}}, nil)
mockDocker.OnVolumeCreate(ctx, volume.VolumeCreateBody{Name: "test"}).Return(expected, nil)
mockDocker.OnVolumeList(ctx, volume.ListOptions{Filters: filters.NewArgs(filters.KeyValuePair{Key: "name", Value: "^test$"})}).Return(volume.ListResponse{Volumes: []*volume.Volume{}}, nil)
mockDocker.OnVolumeCreate(ctx, volume.CreateOptions{Name: "test"}).Return(expected, nil)
actual, err := GetOrCreateVolume(ctx, mockDocker, "test", false)
assert.Equal(t, expected, *actual, "volumes should match")
assert.Nil(t, err)
Expand Down Expand Up @@ -477,7 +477,7 @@ func TestCopyFile(t *testing.T) {
mockDocker := &mocks.Docker{}
mockDocker.OnContainerCreate(
ctx, &container.Config{Image: image}, &container.HostConfig{}, nil, nil, containerName).Return(
container.ContainerCreateCreatedBody{ID: containerName}, nil)
container.CreateResponse{ID: containerName}, nil)
mockDocker.OnContainerStatPath(ctx, containerName, "some source").Return(types.ContainerPathStat{}, nil)
mockDocker.OnCopyFromContainer(ctx, containerName, "some source").Return(reader, types.ContainerPathStat{}, nil)
mockDocker.OnContainerRemove(ctx, containerName, types.ContainerRemoveOptions{Force: true}).Return(nil)
Expand All @@ -500,7 +500,7 @@ func TestCopyFile(t *testing.T) {
mockDocker := &mocks.Docker{}
mockDocker.OnContainerCreate(
ctx, &container.Config{Image: image}, &container.HostConfig{}, nil, nil, containerName).Return(
container.ContainerCreateCreatedBody{ID: containerName}, nil)
container.CreateResponse{ID: containerName}, nil)
mockDocker.OnContainerStatPath(ctx, containerName, "some source").Return(types.ContainerPathStat{}, myErr)
mockDocker.OnContainerRemove(ctx, containerName, types.ContainerRemoveOptions{Force: true}).Return(nil)
assert.Nil(t, err)
Expand Down
72 changes: 35 additions & 37 deletions flytectl/pkg/docker/mocks/docker.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions flytectl/pkg/sandbox/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ func sandboxSetup() {
mockDocker = &mocks.Docker{}
errCh := make(chan error)
sandboxCmdConfig.DefaultConfig.Version = "v0.19.1"
bodyStatus := make(chan container.ContainerWaitOKBody)
bodyStatus := make(chan container.WaitResponse)
githubMock = &ghMocks.GHRepoService{}
sandboxCmdConfig.DefaultConfig.Image = "dummyimage"
mockDocker.OnVolumeList(ctx, filters.NewArgs(filters.KeyValuePair{Key: "name", Value: fmt.Sprintf("^%s$", docker.FlyteSandboxVolumeName)})).Return(volume.VolumeListOKBody{Volumes: []*types.Volume{}}, nil)
mockDocker.OnVolumeCreate(ctx, volume.VolumeCreateBody{Name: docker.FlyteSandboxVolumeName}).Return(types.Volume{Name: docker.FlyteSandboxVolumeName}, nil)
mockDocker.OnContainerCreateMatch(mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(container.ContainerCreateCreatedBody{
mockDocker.OnVolumeList(ctx, volume.ListOptions{Filters: filters.NewArgs(filters.KeyValuePair{Key: "name", Value: fmt.Sprintf("^%s$", docker.FlyteSandboxVolumeName)})}).Return(volume.ListResponse{Volumes: []*volume.Volume{}}, nil)
mockDocker.OnVolumeCreate(ctx, volume.CreateOptions{Name: docker.FlyteSandboxVolumeName}).Return(volume.Volume{Name: docker.FlyteSandboxVolumeName}, nil)
mockDocker.OnContainerCreateMatch(mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(container.CreateResponse{
ID: "Hello",
}, nil)

Expand Down Expand Up @@ -139,8 +139,8 @@ func TestStartFunc(t *testing.T) {
Timestamps: true,
Follow: true,
}).Return(nil, nil)
mockDocker.OnVolumeList(ctx, filters.NewArgs(filters.KeyValuePair{Key: mock.Anything, Value: mock.Anything})).Return(volume.VolumeListOKBody{Volumes: []*types.Volume{}}, nil)
mockDocker.OnVolumeCreate(ctx, volume.VolumeCreateBody{Name: mock.Anything}).Return(types.Volume{}, nil)
mockDocker.OnVolumeList(ctx, volume.ListOptions{Filters: filters.NewArgs(filters.KeyValuePair{Key: mock.Anything, Value: mock.Anything})}).Return(volume.ListResponse{Volumes: []*volume.Volume{}}, nil)
mockDocker.OnVolumeCreate(ctx, volume.CreateOptions{Name: mock.Anything}).Return(volume.Volume{}, nil)
_, err := startSandbox(ctx, mockDocker, githubMock, dummyReader(), config, sandboxImageName, defaultImagePrefix, exposedPorts, portBindings, util.SandBoxConsolePort)
assert.Nil(t, err)
})
Expand Down

0 comments on commit 7b82397

Please sign in to comment.