From 9670d9364dc1b0a2c94b5290f7f865816b34a152 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 25 Aug 2023 23:51:48 +0200 Subject: [PATCH] api/types: move ContainerListOptions to api/types/container Signed-off-by: Sebastiaan van Stijn --- api/server/router/container/backend.go | 2 +- .../router/container/container_routes.go | 2 +- api/types/client.go | 11 ------ api/types/container/options.go | 13 +++++++ api/types/types_deprecated.go | 5 +++ client/client.go | 8 ++--- client/container_list.go | 3 +- client/container_list_test.go | 5 +-- client/interface.go | 2 +- client/request_test.go | 4 +-- daemon/cluster/executor/backend.go | 2 +- daemon/cluster/swarm.go | 3 +- daemon/daemon.go | 2 +- daemon/disk_usage.go | 3 +- daemon/list.go | 35 ++++++++++--------- daemon/list_test.go | 10 +++--- integration-cli/docker_api_containers_test.go | 4 +-- integration/build/build_test.go | 3 +- integration/container/links_linux_test.go | 4 +-- integration/container/ps_test.go | 5 +-- integration/service/create_test.go | 3 +- testutil/daemon/container.go | 4 +-- testutil/environment/clean.go | 4 +-- testutil/environment/protect.go | 3 +- 24 files changed, 78 insertions(+), 62 deletions(-) diff --git a/api/server/router/container/backend.go b/api/server/router/container/backend.go index c69273680a..4a83f1a124 100644 --- a/api/server/router/container/backend.go +++ b/api/server/router/container/backend.go @@ -53,7 +53,7 @@ type monitorBackend interface { ContainerLogs(ctx context.Context, name string, config *types.ContainerLogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error) ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error ContainerTop(name string, psArgs string) (*container.ContainerTopOKBody, error) - Containers(ctx context.Context, config *types.ContainerListOptions) ([]*types.Container, error) + Containers(ctx context.Context, config *container.ListOptions) ([]*types.Container, error) } // attachBackend includes function to implement to provide container attaching functionality. diff --git a/api/server/router/container/container_routes.go b/api/server/router/container/container_routes.go index 87faf9e811..ee381bc574 100644 --- a/api/server/router/container/container_routes.go +++ b/api/server/router/container/container_routes.go @@ -78,7 +78,7 @@ func (s *containerRouter) getContainersJSON(ctx context.Context, w http.Response return err } - config := &types.ContainerListOptions{ + config := &container.ListOptions{ All: httputils.BoolValue(r, "all"), Size: httputils.BoolValue(r, "size"), Since: r.Form.Get("since"), diff --git a/api/types/client.go b/api/types/client.go index a832b60e72..904a7f859f 100644 --- a/api/types/client.go +++ b/api/types/client.go @@ -20,17 +20,6 @@ type ContainerExecInspect struct { Pid int } -// ContainerListOptions holds parameters to list containers with. -type ContainerListOptions struct { - Size bool - All bool - Latest bool - Since string - Before string - Limit int - Filters filters.Args -} - // ContainerLogsOptions holds parameters to filter logs with. type ContainerLogsOptions struct { ShowStdout bool diff --git a/api/types/container/options.go b/api/types/container/options.go index 1952a20614..7ddf33c687 100644 --- a/api/types/container/options.go +++ b/api/types/container/options.go @@ -1,5 +1,7 @@ package container +import "github.com/docker/docker/api/types/filters" + // ResizeOptions holds parameters to resize a TTY. // It can be used to resize container TTYs and // exec process TTYs too. @@ -40,3 +42,14 @@ type StartOptions struct { CheckpointID string CheckpointDir string } + +// ListOptions holds parameters to list containers with. +type ListOptions struct { + Size bool + All bool + Latest bool + Since string + Before string + Limit int + Filters filters.Args +} diff --git a/api/types/types_deprecated.go b/api/types/types_deprecated.go index 1fdffe7091..7d4e919c3a 100644 --- a/api/types/types_deprecated.go +++ b/api/types/types_deprecated.go @@ -114,6 +114,11 @@ type ContainerAttachOptions = container.AttachOptions // Deprecated: use [container.CommitOptions]. type ContainerCommitOptions = container.CommitOptions +// ContainerListOptions holds parameters to list containers with. +// +// Deprecated: use [container.ListOptions]. +type ContainerListOptions = container.ListOptions + // ContainerRemoveOptions holds parameters to remove containers. // // Deprecated: use [container.RemoveOptions]. diff --git a/client/client.go b/client/client.go index 7eab41185d..6fb3f3eb04 100644 --- a/client/client.go +++ b/client/client.go @@ -19,7 +19,7 @@ For example, to list running containers (the equivalent of "docker ps"): "context" "fmt" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/client" ) @@ -29,13 +29,13 @@ For example, to list running containers (the equivalent of "docker ps"): panic(err) } - containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{}) + containers, err := cli.ContainerList(context.Background(), container.ListOptions{}) if err != nil { panic(err) } - for _, container := range containers { - fmt.Printf("%s %s\n", container.ID[:10], container.Image) + for _, ctr := range containers { + fmt.Printf("%s %s\n", ctr.ID, ctr.Image) } } */ diff --git a/client/container_list.go b/client/container_list.go index 127a57cfd8..782e1b3c62 100644 --- a/client/container_list.go +++ b/client/container_list.go @@ -7,11 +7,12 @@ import ( "strconv" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" ) // ContainerList returns the list of containers in the docker host. -func (cli *Client) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error) { +func (cli *Client) ContainerList(ctx context.Context, options container.ListOptions) ([]types.Container, error) { query := url.Values{} if options.All { diff --git a/client/container_list_test.go b/client/container_list_test.go index 920231edba..dbe4647af1 100644 --- a/client/container_list_test.go +++ b/client/container_list_test.go @@ -11,6 +11,7 @@ import ( "testing" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" @@ -21,7 +22,7 @@ func TestContainerListError(t *testing.T) { client := &Client{ client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - _, err := client.ContainerList(context.Background(), types.ContainerListOptions{}) + _, err := client.ContainerList(context.Background(), container.ListOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) } @@ -78,7 +79,7 @@ func TestContainerList(t *testing.T) { }), } - containers, err := client.ContainerList(context.Background(), types.ContainerListOptions{ + containers, err := client.ContainerList(context.Background(), container.ListOptions{ Size: true, All: true, Since: "container", diff --git a/client/interface.go b/client/interface.go index 2185c357a6..30b7d533e7 100644 --- a/client/interface.go +++ b/client/interface.go @@ -59,7 +59,7 @@ type ContainerAPIClient interface { ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error) ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (types.ContainerJSON, []byte, error) ContainerKill(ctx context.Context, container, signal string) error - ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error) + ContainerList(ctx context.Context, options container.ListOptions) ([]types.Container, error) ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error) ContainerPause(ctx context.Context, container string) error ContainerRemove(ctx context.Context, container string, options container.RemoveOptions) error diff --git a/client/request_test.go b/client/request_test.go index 6bc47fef39..127c567b5f 100644 --- a/client/request_test.go +++ b/client/request_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -90,7 +90,7 @@ func TestPlainTextError(t *testing.T) { client := &Client{ client: newMockClient(plainTextErrorMock(http.StatusInternalServerError, "Server error")), } - _, err := client.ContainerList(context.Background(), types.ContainerListOptions{}) + _, err := client.ContainerList(context.Background(), container.ListOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) } diff --git a/daemon/cluster/executor/backend.go b/daemon/cluster/executor/backend.go index 9bfdc03278..d24dbc28ae 100644 --- a/daemon/cluster/executor/backend.go +++ b/daemon/cluster/executor/backend.go @@ -54,7 +54,7 @@ type Backend interface { SetContainerSecretReferences(name string, refs []*swarm.SecretReference) error SetContainerConfigReferences(name string, refs []*swarm.ConfigReference) error SystemInfo() *system.Info - Containers(ctx context.Context, config *types.ContainerListOptions) ([]*types.Container, error) + Containers(ctx context.Context, config *container.ListOptions) ([]*types.Container, error) SetNetworkBootstrapKeys([]*networktypes.EncryptionKey) error DaemonJoinsCluster(provider cluster.Provider) DaemonLeavesCluster() diff --git a/daemon/cluster/swarm.go b/daemon/cluster/swarm.go index e5e51d92e7..1a820d67e6 100644 --- a/daemon/cluster/swarm.go +++ b/daemon/cluster/swarm.go @@ -9,6 +9,7 @@ import ( "github.com/containerd/log" apitypes "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" types "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/daemon/cluster/convert" @@ -606,7 +607,7 @@ func initClusterSpec(node *swarmnode.Node, spec types.Spec) error { func (c *Cluster) listContainerForNode(ctx context.Context, nodeID string) ([]string, error) { var ids []string - containers, err := c.config.Backend.Containers(ctx, &apitypes.ContainerListOptions{ + containers, err := c.config.Backend.Containers(ctx, &container.ListOptions{ Filters: filters.NewArgs(filters.Arg("label", "com.docker.swarm.node.id="+nodeID)), }) if err != nil { diff --git a/daemon/daemon.go b/daemon/daemon.go index ac9872e539..813f1c5afb 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -1266,7 +1266,7 @@ func (daemon *Daemon) Shutdown(ctx context.Context) error { cfg := &daemon.config().Config if cfg.LiveRestoreEnabled && daemon.containers != nil { // check if there are any running containers, if none we should do some cleanup - if ls, err := daemon.Containers(ctx, &types.ContainerListOptions{}); len(ls) != 0 || err != nil { + if ls, err := daemon.Containers(ctx, &containertypes.ListOptions{}); len(ls) != 0 || err != nil { // metrics plugins still need some cleanup daemon.cleanupMetricsPlugins() return err diff --git a/daemon/disk_usage.go b/daemon/disk_usage.go index e66e917d68..f9987e2dd1 100644 --- a/daemon/disk_usage.go +++ b/daemon/disk_usage.go @@ -6,6 +6,7 @@ import ( "github.com/docker/docker/api/server/router/system" "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/image" "github.com/docker/docker/api/types/volume" @@ -18,7 +19,7 @@ import ( func (daemon *Daemon) containerDiskUsage(ctx context.Context) ([]*types.Container, error) { res, _, err := daemon.usageContainers.Do(ctx, struct{}{}, func(ctx context.Context) ([]*types.Container, error) { // Retrieve container list - containers, err := daemon.Containers(ctx, &types.ContainerListOptions{ + containers, err := daemon.Containers(ctx, &container.ListOptions{ Size: true, All: true, }) diff --git a/daemon/list.go b/daemon/list.go index 5949bde858..d367e19015 100644 --- a/daemon/list.go +++ b/daemon/list.go @@ -9,6 +9,7 @@ import ( "github.com/containerd/log" "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" imagetypes "github.com/docker/docker/api/types/image" "github.com/docker/docker/container" @@ -54,7 +55,7 @@ func (daemon *Daemon) List() []*container.Container { } // listContext is the daemon generated filtering to iterate over containers. -// This is created based on the user specification from types.ContainerListOptions. +// This is created based on the user specification from [containertypes.ListOptions]. type listContext struct { // idx is the container iteration index for this context idx int @@ -84,8 +85,8 @@ type listContext struct { // expose is a list of exposed ports to filter with expose map[nat.Port]bool - // ContainerListOptions is the filters set by the user - *types.ContainerListOptions + // ListOptions is the filters set by the user + *containertypes.ListOptions } // byCreatedDescending is a temporary type used to sort a list of containers by creation time. @@ -98,7 +99,7 @@ func (r byCreatedDescending) Less(i, j int) bool { } // Containers returns the list of containers to show given the user's filtering. -func (daemon *Daemon) Containers(ctx context.Context, config *types.ContainerListOptions) ([]*types.Container, error) { +func (daemon *Daemon) Containers(ctx context.Context, config *containertypes.ListOptions) ([]*types.Container, error) { if err := config.Filters.Validate(acceptedPsFilterTags); err != nil { return nil, err } @@ -224,7 +225,7 @@ func (daemon *Daemon) filterByNameIDMatches(view *container.View, filter *listCo } // foldFilter generates the container filter based on the user's filtering options. -func (daemon *Daemon) foldFilter(ctx context.Context, view *container.View, config *types.ContainerListOptions) (*listContext, error) { +func (daemon *Daemon) foldFilter(ctx context.Context, view *container.View, config *containertypes.ListOptions) (*listContext, error) { psFilters := config.Filters var filtExited []int @@ -323,18 +324,18 @@ func (daemon *Daemon) foldFilter(ctx context.Context, view *container.View, conf } return &listContext{ - filters: psFilters, - ancestorFilter: ancestorFilter, - images: imagesFilter, - exitAllowed: filtExited, - beforeFilter: beforeContFilter, - sinceFilter: sinceContFilter, - taskFilter: taskFilter, - isTask: isTask, - publish: publishFilter, - expose: exposeFilter, - ContainerListOptions: config, - names: view.GetAllNames(), + filters: psFilters, + ancestorFilter: ancestorFilter, + images: imagesFilter, + exitAllowed: filtExited, + beforeFilter: beforeContFilter, + sinceFilter: sinceContFilter, + taskFilter: taskFilter, + isTask: isTask, + publish: publishFilter, + expose: exposeFilter, + ListOptions: config, + names: view.GetAllNames(), }, nil } diff --git a/daemon/list_test.go b/daemon/list_test.go index 982575bc1e..33e54c0ded 100644 --- a/daemon/list_test.go +++ b/daemon/list_test.go @@ -87,7 +87,7 @@ func TestListInvalidFilter(t *testing.T) { containersReplica: db, } - _, err = d.Containers(context.Background(), &types.ContainerListOptions{ + _, err = d.Containers(context.Background(), &containertypes.ListOptions{ Filters: filters.NewArgs(filters.Arg("invalid", "foo")), }) assert.Assert(t, is.Error(err, "invalid filter 'invalid'")) @@ -108,7 +108,7 @@ func TestNameFilter(t *testing.T) { // moby/moby #37453 - ^ regex not working due to prefix slash // not being stripped - containerList, err := d.Containers(context.Background(), &types.ContainerListOptions{ + containerList, err := d.Containers(context.Background(), &containertypes.ListOptions{ Filters: filters.NewArgs(filters.Arg("name", "^a")), }) assert.NilError(t, err) @@ -117,7 +117,7 @@ func TestNameFilter(t *testing.T) { assert.Assert(t, containerListContainsName(containerList, two.Name)) // Same as above but with slash prefix should produce the same result - containerListWithPrefix, err := d.Containers(context.Background(), &types.ContainerListOptions{ + containerListWithPrefix, err := d.Containers(context.Background(), &containertypes.ListOptions{ Filters: filters.NewArgs(filters.Arg("name", "^/a")), }) assert.NilError(t, err) @@ -126,7 +126,7 @@ func TestNameFilter(t *testing.T) { assert.Assert(t, containerListContainsName(containerListWithPrefix, two.Name)) // Same as above but make sure it works for exact names - containerList, err = d.Containers(context.Background(), &types.ContainerListOptions{ + containerList, err = d.Containers(context.Background(), &containertypes.ListOptions{ Filters: filters.NewArgs(filters.Arg("name", "b1")), }) assert.NilError(t, err) @@ -134,7 +134,7 @@ func TestNameFilter(t *testing.T) { assert.Assert(t, containerListContainsName(containerList, three.Name)) // Same as above but with slash prefix should produce the same result - containerListWithPrefix, err = d.Containers(context.Background(), &types.ContainerListOptions{ + containerListWithPrefix, err = d.Containers(context.Background(), &containertypes.ListOptions{ Filters: filters.NewArgs(filters.Arg("name", "/b1")), }) assert.NilError(t, err) diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go index a8f02a8ff7..69bcc2fa35 100644 --- a/integration-cli/docker_api_containers_test.go +++ b/integration-cli/docker_api_containers_test.go @@ -45,7 +45,7 @@ func (s *DockerAPISuite) TestContainerAPIGetAll(c *testing.T) { assert.NilError(c, err) defer apiClient.Close() - options := types.ContainerListOptions{ + options := container.ListOptions{ All: true, } ctx := testutil.GetContext(c) @@ -65,7 +65,7 @@ func (s *DockerAPISuite) TestContainerAPIGetJSONNoFieldsOmitted(c *testing.T) { assert.NilError(c, err) defer apiClient.Close() - options := types.ContainerListOptions{ + options := container.ListOptions{ All: true, } ctx := testutil.GetContext(c) diff --git a/integration/build/build_test.go b/integration/build/build_test.go index b009bdefff..4b01f21121 100644 --- a/integration/build/build_test.go +++ b/integration/build/build_test.go @@ -10,6 +10,7 @@ import ( "testing" "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/versions" "github.com/docker/docker/errdefs" @@ -109,7 +110,7 @@ func TestBuildWithRemoveAndForceRemove(t *testing.T) { defer resp.Body.Close() filter, err := buildContainerIdsFilter(resp.Body) assert.NilError(t, err) - remainingContainers, err := client.ContainerList(ctx, types.ContainerListOptions{Filters: filter, All: true}) + remainingContainers, err := client.ContainerList(ctx, container.ListOptions{Filters: filter, All: true}) assert.NilError(t, err) assert.Equal(t, c.numberOfIntermediateContainers, len(remainingContainers), "Expected %v remaining intermediate containers, got %v", c.numberOfIntermediateContainers, len(remainingContainers)) }) diff --git a/integration/container/links_linux_test.go b/integration/container/links_linux_test.go index 92d4cc1514..15d3dacd4a 100644 --- a/integration/container/links_linux_test.go +++ b/integration/container/links_linux_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/integration/internal/container" "gotest.tools/v3/assert" @@ -43,7 +43,7 @@ func TestLinksContainerNames(t *testing.T) { container.Run(ctx, t, apiClient, container.WithName(containerA)) container.Run(ctx, t, apiClient, container.WithName(containerB), container.WithLinks(containerA+":"+containerA)) - containers, err := apiClient.ContainerList(ctx, types.ContainerListOptions{ + containers, err := apiClient.ContainerList(ctx, containertypes.ListOptions{ Filters: filters.NewArgs(filters.Arg("name", containerA)), }) assert.NilError(t, err) diff --git a/integration/container/ps_test.go b/integration/container/ps_test.go index 048e541a2b..d452ba2665 100644 --- a/integration/container/ps_test.go +++ b/integration/container/ps_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/testutil" @@ -29,7 +30,7 @@ func TestPsFilter(t *testing.T) { t.Run("since", func(t *testing.T) { ctx := testutil.StartSpan(ctx, t) - results, err := apiClient.ContainerList(ctx, types.ContainerListOptions{ + results, err := apiClient.ContainerList(ctx, containertypes.ListOptions{ All: true, Filters: filters.NewArgs(filters.Arg("since", top)), }) @@ -39,7 +40,7 @@ func TestPsFilter(t *testing.T) { t.Run("before", func(t *testing.T) { ctx := testutil.StartSpan(ctx, t) - results, err := apiClient.ContainerList(ctx, types.ContainerListOptions{ + results, err := apiClient.ContainerList(ctx, containertypes.ListOptions{ All: true, Filters: filters.NewArgs(filters.Arg("before", top)), }) diff --git a/integration/service/create_test.go b/integration/service/create_test.go index 877dbb0284..6b56fc1c00 100644 --- a/integration/service/create_test.go +++ b/integration/service/create_test.go @@ -8,6 +8,7 @@ import ( "time" "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/strslice" swarmtypes "github.com/docker/docker/api/types/swarm" @@ -66,7 +67,7 @@ func testServiceCreateInit(ctx context.Context, daemonEnabled bool) func(t *test func inspectServiceContainer(ctx context.Context, t *testing.T, client client.APIClient, serviceID string) types.ContainerJSON { t.Helper() - containers, err := client.ContainerList(ctx, types.ContainerListOptions{ + containers, err := client.ContainerList(ctx, container.ListOptions{ Filters: filters.NewArgs(filters.Arg("label", "com.docker.swarm.service.id="+serviceID)), }) assert.NilError(t, err) diff --git a/testutil/daemon/container.go b/testutil/daemon/container.go index 42dafe7f5c..3dccfc5898 100644 --- a/testutil/daemon/container.go +++ b/testutil/daemon/container.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "gotest.tools/v3/assert" ) @@ -14,7 +14,7 @@ func (d *Daemon) ActiveContainers(ctx context.Context, t testing.TB) []string { cli := d.NewClientT(t) defer cli.Close() - containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{}) + containers, err := cli.ContainerList(context.Background(), container.ListOptions{}) assert.NilError(t, err) ids := make([]string, len(containers)) diff --git a/testutil/environment/clean.go b/testutil/environment/clean.go index 6893de7b01..a545d31400 100644 --- a/testutil/environment/clean.go +++ b/testutil/environment/clean.go @@ -53,7 +53,7 @@ func unpauseAllContainers(ctx context.Context, t testing.TB, client client.Conta func getPausedContainers(ctx context.Context, t testing.TB, client client.ContainerAPIClient) []types.Container { t.Helper() - containers, err := client.ContainerList(ctx, types.ContainerListOptions{ + containers, err := client.ContainerList(ctx, container.ListOptions{ Filters: filters.NewArgs(filters.Arg("status", "paused")), All: true, }) @@ -87,7 +87,7 @@ func deleteAllContainers(ctx context.Context, t testing.TB, apiclient client.Con func getAllContainers(ctx context.Context, t testing.TB, client client.ContainerAPIClient) []types.Container { t.Helper() - containers, err := client.ContainerList(ctx, types.ContainerListOptions{ + containers, err := client.ContainerList(ctx, container.ListOptions{ All: true, }) assert.Check(t, err, "failed to list containers") diff --git a/testutil/environment/protect.go b/testutil/environment/protect.go index a398f25a9d..aa60361fd9 100644 --- a/testutil/environment/protect.go +++ b/testutil/environment/protect.go @@ -5,6 +5,7 @@ import ( "testing" "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/image" "github.com/docker/docker/api/types/volume" @@ -70,7 +71,7 @@ func ProtectContainers(ctx context.Context, t testing.TB, testEnv *Execution) { func getExistingContainers(ctx context.Context, t testing.TB, testEnv *Execution) []string { t.Helper() client := testEnv.APIClient() - containerList, err := client.ContainerList(ctx, types.ContainerListOptions{ + containerList, err := client.ContainerList(ctx, container.ListOptions{ All: true, }) assert.NilError(t, err, "failed to list containers")