api/types: move ContainerListOptions to api/types/container
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
7bce33eb0f
commit
9670d9364d
24 changed files with 78 additions and 62 deletions
|
@ -53,7 +53,7 @@ type monitorBackend interface {
|
||||||
ContainerLogs(ctx context.Context, name string, config *types.ContainerLogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error)
|
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
|
ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error
|
||||||
ContainerTop(name string, psArgs string) (*container.ContainerTopOKBody, 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.
|
// attachBackend includes function to implement to provide container attaching functionality.
|
||||||
|
|
|
@ -78,7 +78,7 @@ func (s *containerRouter) getContainersJSON(ctx context.Context, w http.Response
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
config := &types.ContainerListOptions{
|
config := &container.ListOptions{
|
||||||
All: httputils.BoolValue(r, "all"),
|
All: httputils.BoolValue(r, "all"),
|
||||||
Size: httputils.BoolValue(r, "size"),
|
Size: httputils.BoolValue(r, "size"),
|
||||||
Since: r.Form.Get("since"),
|
Since: r.Form.Get("since"),
|
||||||
|
|
|
@ -20,17 +20,6 @@ type ContainerExecInspect struct {
|
||||||
Pid int
|
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.
|
// ContainerLogsOptions holds parameters to filter logs with.
|
||||||
type ContainerLogsOptions struct {
|
type ContainerLogsOptions struct {
|
||||||
ShowStdout bool
|
ShowStdout bool
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package container
|
package container
|
||||||
|
|
||||||
|
import "github.com/docker/docker/api/types/filters"
|
||||||
|
|
||||||
// ResizeOptions holds parameters to resize a TTY.
|
// ResizeOptions holds parameters to resize a TTY.
|
||||||
// It can be used to resize container TTYs and
|
// It can be used to resize container TTYs and
|
||||||
// exec process TTYs too.
|
// exec process TTYs too.
|
||||||
|
@ -40,3 +42,14 @@ type StartOptions struct {
|
||||||
CheckpointID string
|
CheckpointID string
|
||||||
CheckpointDir 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
|
||||||
|
}
|
||||||
|
|
|
@ -114,6 +114,11 @@ type ContainerAttachOptions = container.AttachOptions
|
||||||
// Deprecated: use [container.CommitOptions].
|
// Deprecated: use [container.CommitOptions].
|
||||||
type ContainerCommitOptions = 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.
|
// ContainerRemoveOptions holds parameters to remove containers.
|
||||||
//
|
//
|
||||||
// Deprecated: use [container.RemoveOptions].
|
// Deprecated: use [container.RemoveOptions].
|
||||||
|
|
|
@ -19,7 +19,7 @@ For example, to list running containers (the equivalent of "docker ps"):
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -29,13 +29,13 @@ For example, to list running containers (the equivalent of "docker ps"):
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{})
|
containers, err := cli.ContainerList(context.Background(), container.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, container := range containers {
|
for _, ctr := range containers {
|
||||||
fmt.Printf("%s %s\n", container.ID[:10], container.Image)
|
fmt.Printf("%s %s\n", ctr.ID, ctr.Image)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -7,11 +7,12 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"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/filters"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ContainerList returns the list of containers in the docker host.
|
// 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{}
|
query := url.Values{}
|
||||||
|
|
||||||
if options.All {
|
if options.All {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"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/filters"
|
||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
|
@ -21,7 +22,7 @@ func TestContainerListError(t *testing.T) {
|
||||||
client := &Client{
|
client := &Client{
|
||||||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
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))
|
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,
|
Size: true,
|
||||||
All: true,
|
All: true,
|
||||||
Since: "container",
|
Since: "container",
|
||||||
|
|
|
@ -59,7 +59,7 @@ type ContainerAPIClient interface {
|
||||||
ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error)
|
ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error)
|
||||||
ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (types.ContainerJSON, []byte, error)
|
ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (types.ContainerJSON, []byte, error)
|
||||||
ContainerKill(ctx context.Context, container, signal string) 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)
|
ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error)
|
||||||
ContainerPause(ctx context.Context, container string) error
|
ContainerPause(ctx context.Context, container string) error
|
||||||
ContainerRemove(ctx context.Context, container string, options container.RemoveOptions) error
|
ContainerRemove(ctx context.Context, container string, options container.RemoveOptions) error
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
|
@ -90,7 +90,7 @@ func TestPlainTextError(t *testing.T) {
|
||||||
client := &Client{
|
client := &Client{
|
||||||
client: newMockClient(plainTextErrorMock(http.StatusInternalServerError, "Server error")),
|
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))
|
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ type Backend interface {
|
||||||
SetContainerSecretReferences(name string, refs []*swarm.SecretReference) error
|
SetContainerSecretReferences(name string, refs []*swarm.SecretReference) error
|
||||||
SetContainerConfigReferences(name string, refs []*swarm.ConfigReference) error
|
SetContainerConfigReferences(name string, refs []*swarm.ConfigReference) error
|
||||||
SystemInfo() *system.Info
|
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
|
SetNetworkBootstrapKeys([]*networktypes.EncryptionKey) error
|
||||||
DaemonJoinsCluster(provider cluster.Provider)
|
DaemonJoinsCluster(provider cluster.Provider)
|
||||||
DaemonLeavesCluster()
|
DaemonLeavesCluster()
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
"github.com/containerd/log"
|
"github.com/containerd/log"
|
||||||
apitypes "github.com/docker/docker/api/types"
|
apitypes "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/filters"
|
||||||
types "github.com/docker/docker/api/types/swarm"
|
types "github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/daemon/cluster/convert"
|
"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) {
|
func (c *Cluster) listContainerForNode(ctx context.Context, nodeID string) ([]string, error) {
|
||||||
var ids []string
|
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)),
|
Filters: filters.NewArgs(filters.Arg("label", "com.docker.swarm.node.id="+nodeID)),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1266,7 +1266,7 @@ func (daemon *Daemon) Shutdown(ctx context.Context) error {
|
||||||
cfg := &daemon.config().Config
|
cfg := &daemon.config().Config
|
||||||
if cfg.LiveRestoreEnabled && daemon.containers != nil {
|
if cfg.LiveRestoreEnabled && daemon.containers != nil {
|
||||||
// check if there are any running containers, if none we should do some cleanup
|
// 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
|
// metrics plugins still need some cleanup
|
||||||
daemon.cleanupMetricsPlugins()
|
daemon.cleanupMetricsPlugins()
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/docker/api/server/router/system"
|
"github.com/docker/docker/api/server/router/system"
|
||||||
"github.com/docker/docker/api/types"
|
"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/filters"
|
||||||
"github.com/docker/docker/api/types/image"
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/volume"
|
"github.com/docker/docker/api/types/volume"
|
||||||
|
@ -18,7 +19,7 @@ import (
|
||||||
func (daemon *Daemon) containerDiskUsage(ctx context.Context) ([]*types.Container, error) {
|
func (daemon *Daemon) containerDiskUsage(ctx context.Context) ([]*types.Container, error) {
|
||||||
res, _, err := daemon.usageContainers.Do(ctx, struct{}{}, func(ctx context.Context) ([]*types.Container, error) {
|
res, _, err := daemon.usageContainers.Do(ctx, struct{}{}, func(ctx context.Context) ([]*types.Container, error) {
|
||||||
// Retrieve container list
|
// Retrieve container list
|
||||||
containers, err := daemon.Containers(ctx, &types.ContainerListOptions{
|
containers, err := daemon.Containers(ctx, &container.ListOptions{
|
||||||
Size: true,
|
Size: true,
|
||||||
All: true,
|
All: true,
|
||||||
})
|
})
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
"github.com/containerd/log"
|
"github.com/containerd/log"
|
||||||
"github.com/docker/docker/api/types"
|
"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/api/types/filters"
|
||||||
imagetypes "github.com/docker/docker/api/types/image"
|
imagetypes "github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/container"
|
"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.
|
// 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 {
|
type listContext struct {
|
||||||
// idx is the container iteration index for this context
|
// idx is the container iteration index for this context
|
||||||
idx int
|
idx int
|
||||||
|
@ -84,8 +85,8 @@ type listContext struct {
|
||||||
// expose is a list of exposed ports to filter with
|
// expose is a list of exposed ports to filter with
|
||||||
expose map[nat.Port]bool
|
expose map[nat.Port]bool
|
||||||
|
|
||||||
// ContainerListOptions is the filters set by the user
|
// ListOptions is the filters set by the user
|
||||||
*types.ContainerListOptions
|
*containertypes.ListOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
// byCreatedDescending is a temporary type used to sort a list of containers by creation time.
|
// 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.
|
// 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 {
|
if err := config.Filters.Validate(acceptedPsFilterTags); err != nil {
|
||||||
return nil, err
|
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.
|
// 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
|
psFilters := config.Filters
|
||||||
|
|
||||||
var filtExited []int
|
var filtExited []int
|
||||||
|
@ -323,18 +324,18 @@ func (daemon *Daemon) foldFilter(ctx context.Context, view *container.View, conf
|
||||||
}
|
}
|
||||||
|
|
||||||
return &listContext{
|
return &listContext{
|
||||||
filters: psFilters,
|
filters: psFilters,
|
||||||
ancestorFilter: ancestorFilter,
|
ancestorFilter: ancestorFilter,
|
||||||
images: imagesFilter,
|
images: imagesFilter,
|
||||||
exitAllowed: filtExited,
|
exitAllowed: filtExited,
|
||||||
beforeFilter: beforeContFilter,
|
beforeFilter: beforeContFilter,
|
||||||
sinceFilter: sinceContFilter,
|
sinceFilter: sinceContFilter,
|
||||||
taskFilter: taskFilter,
|
taskFilter: taskFilter,
|
||||||
isTask: isTask,
|
isTask: isTask,
|
||||||
publish: publishFilter,
|
publish: publishFilter,
|
||||||
expose: exposeFilter,
|
expose: exposeFilter,
|
||||||
ContainerListOptions: config,
|
ListOptions: config,
|
||||||
names: view.GetAllNames(),
|
names: view.GetAllNames(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ func TestListInvalidFilter(t *testing.T) {
|
||||||
containersReplica: db,
|
containersReplica: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = d.Containers(context.Background(), &types.ContainerListOptions{
|
_, err = d.Containers(context.Background(), &containertypes.ListOptions{
|
||||||
Filters: filters.NewArgs(filters.Arg("invalid", "foo")),
|
Filters: filters.NewArgs(filters.Arg("invalid", "foo")),
|
||||||
})
|
})
|
||||||
assert.Assert(t, is.Error(err, "invalid filter 'invalid'"))
|
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
|
// moby/moby #37453 - ^ regex not working due to prefix slash
|
||||||
// not being stripped
|
// 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")),
|
Filters: filters.NewArgs(filters.Arg("name", "^a")),
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
@ -117,7 +117,7 @@ func TestNameFilter(t *testing.T) {
|
||||||
assert.Assert(t, containerListContainsName(containerList, two.Name))
|
assert.Assert(t, containerListContainsName(containerList, two.Name))
|
||||||
|
|
||||||
// Same as above but with slash prefix should produce the same result
|
// 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")),
|
Filters: filters.NewArgs(filters.Arg("name", "^/a")),
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
@ -126,7 +126,7 @@ func TestNameFilter(t *testing.T) {
|
||||||
assert.Assert(t, containerListContainsName(containerListWithPrefix, two.Name))
|
assert.Assert(t, containerListContainsName(containerListWithPrefix, two.Name))
|
||||||
|
|
||||||
// Same as above but make sure it works for exact names
|
// 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")),
|
Filters: filters.NewArgs(filters.Arg("name", "b1")),
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
@ -134,7 +134,7 @@ func TestNameFilter(t *testing.T) {
|
||||||
assert.Assert(t, containerListContainsName(containerList, three.Name))
|
assert.Assert(t, containerListContainsName(containerList, three.Name))
|
||||||
|
|
||||||
// Same as above but with slash prefix should produce the same result
|
// 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")),
|
Filters: filters.NewArgs(filters.Arg("name", "/b1")),
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
|
@ -45,7 +45,7 @@ func (s *DockerAPISuite) TestContainerAPIGetAll(c *testing.T) {
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
defer apiClient.Close()
|
defer apiClient.Close()
|
||||||
|
|
||||||
options := types.ContainerListOptions{
|
options := container.ListOptions{
|
||||||
All: true,
|
All: true,
|
||||||
}
|
}
|
||||||
ctx := testutil.GetContext(c)
|
ctx := testutil.GetContext(c)
|
||||||
|
@ -65,7 +65,7 @@ func (s *DockerAPISuite) TestContainerAPIGetJSONNoFieldsOmitted(c *testing.T) {
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
defer apiClient.Close()
|
defer apiClient.Close()
|
||||||
|
|
||||||
options := types.ContainerListOptions{
|
options := container.ListOptions{
|
||||||
All: true,
|
All: true,
|
||||||
}
|
}
|
||||||
ctx := testutil.GetContext(c)
|
ctx := testutil.GetContext(c)
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"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/filters"
|
||||||
"github.com/docker/docker/api/types/versions"
|
"github.com/docker/docker/api/types/versions"
|
||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
|
@ -109,7 +110,7 @@ func TestBuildWithRemoveAndForceRemove(t *testing.T) {
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
filter, err := buildContainerIdsFilter(resp.Body)
|
filter, err := buildContainerIdsFilter(resp.Body)
|
||||||
assert.NilError(t, err)
|
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.NilError(t, err)
|
||||||
assert.Equal(t, c.numberOfIntermediateContainers, len(remainingContainers), "Expected %v remaining intermediate containers, got %v", c.numberOfIntermediateContainers, len(remainingContainers))
|
assert.Equal(t, c.numberOfIntermediateContainers, len(remainingContainers), "Expected %v remaining intermediate containers, got %v", c.numberOfIntermediateContainers, len(remainingContainers))
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"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/api/types/filters"
|
||||||
"github.com/docker/docker/integration/internal/container"
|
"github.com/docker/docker/integration/internal/container"
|
||||||
"gotest.tools/v3/assert"
|
"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(containerA))
|
||||||
container.Run(ctx, t, apiClient, container.WithName(containerB), container.WithLinks(containerA+":"+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)),
|
Filters: filters.NewArgs(filters.Arg("name", containerA)),
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"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/api/types/filters"
|
||||||
"github.com/docker/docker/integration/internal/container"
|
"github.com/docker/docker/integration/internal/container"
|
||||||
"github.com/docker/docker/testutil"
|
"github.com/docker/docker/testutil"
|
||||||
|
@ -29,7 +30,7 @@ func TestPsFilter(t *testing.T) {
|
||||||
|
|
||||||
t.Run("since", func(t *testing.T) {
|
t.Run("since", func(t *testing.T) {
|
||||||
ctx := testutil.StartSpan(ctx, t)
|
ctx := testutil.StartSpan(ctx, t)
|
||||||
results, err := apiClient.ContainerList(ctx, types.ContainerListOptions{
|
results, err := apiClient.ContainerList(ctx, containertypes.ListOptions{
|
||||||
All: true,
|
All: true,
|
||||||
Filters: filters.NewArgs(filters.Arg("since", top)),
|
Filters: filters.NewArgs(filters.Arg("since", top)),
|
||||||
})
|
})
|
||||||
|
@ -39,7 +40,7 @@ func TestPsFilter(t *testing.T) {
|
||||||
|
|
||||||
t.Run("before", func(t *testing.T) {
|
t.Run("before", func(t *testing.T) {
|
||||||
ctx := testutil.StartSpan(ctx, t)
|
ctx := testutil.StartSpan(ctx, t)
|
||||||
results, err := apiClient.ContainerList(ctx, types.ContainerListOptions{
|
results, err := apiClient.ContainerList(ctx, containertypes.ListOptions{
|
||||||
All: true,
|
All: true,
|
||||||
Filters: filters.NewArgs(filters.Arg("before", top)),
|
Filters: filters.NewArgs(filters.Arg("before", top)),
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"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/filters"
|
||||||
"github.com/docker/docker/api/types/strslice"
|
"github.com/docker/docker/api/types/strslice"
|
||||||
swarmtypes "github.com/docker/docker/api/types/swarm"
|
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 {
|
func inspectServiceContainer(ctx context.Context, t *testing.T, client client.APIClient, serviceID string) types.ContainerJSON {
|
||||||
t.Helper()
|
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)),
|
Filters: filters.NewArgs(filters.Arg("label", "com.docker.swarm.service.id="+serviceID)),
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/container"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ func (d *Daemon) ActiveContainers(ctx context.Context, t testing.TB) []string {
|
||||||
cli := d.NewClientT(t)
|
cli := d.NewClientT(t)
|
||||||
defer cli.Close()
|
defer cli.Close()
|
||||||
|
|
||||||
containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{})
|
containers, err := cli.ContainerList(context.Background(), container.ListOptions{})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
ids := make([]string, len(containers))
|
ids := make([]string, len(containers))
|
||||||
|
|
|
@ -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 {
|
func getPausedContainers(ctx context.Context, t testing.TB, client client.ContainerAPIClient) []types.Container {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
containers, err := client.ContainerList(ctx, types.ContainerListOptions{
|
containers, err := client.ContainerList(ctx, container.ListOptions{
|
||||||
Filters: filters.NewArgs(filters.Arg("status", "paused")),
|
Filters: filters.NewArgs(filters.Arg("status", "paused")),
|
||||||
All: true,
|
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 {
|
func getAllContainers(ctx context.Context, t testing.TB, client client.ContainerAPIClient) []types.Container {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
containers, err := client.ContainerList(ctx, types.ContainerListOptions{
|
containers, err := client.ContainerList(ctx, container.ListOptions{
|
||||||
All: true,
|
All: true,
|
||||||
})
|
})
|
||||||
assert.Check(t, err, "failed to list containers")
|
assert.Check(t, err, "failed to list containers")
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"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/filters"
|
||||||
"github.com/docker/docker/api/types/image"
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/volume"
|
"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 {
|
func getExistingContainers(ctx context.Context, t testing.TB, testEnv *Execution) []string {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
client := testEnv.APIClient()
|
client := testEnv.APIClient()
|
||||||
containerList, err := client.ContainerList(ctx, types.ContainerListOptions{
|
containerList, err := client.ContainerList(ctx, container.ListOptions{
|
||||||
All: true,
|
All: true,
|
||||||
})
|
})
|
||||||
assert.NilError(t, err, "failed to list containers")
|
assert.NilError(t, err, "failed to list containers")
|
||||||
|
|
Loading…
Reference in a new issue