client, integration-cli: remove unneeded import aliases

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-04-17 13:47:37 +02:00
parent 83a185897d
commit 9060126639
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 168 additions and 168 deletions

View File

@ -8,14 +8,14 @@ import (
"time" "time"
"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/container"
"github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/events"
"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"
networktypes "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
volumetypes "github.com/docker/docker/api/types/volume" "github.com/docker/docker/api/types/volume"
specs "github.com/opencontainers/image-spec/specs-go/v1" specs "github.com/opencontainers/image-spec/specs-go/v1"
) )
@ -48,8 +48,8 @@ type CommonAPIClient interface {
type ContainerAPIClient interface { type ContainerAPIClient interface {
ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error) ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error)
ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error) ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error)
ContainerCreate(ctx context.Context, config *containertypes.Config, hostConfig *containertypes.HostConfig, networkingConfig *networktypes.NetworkingConfig, platform *specs.Platform, containerName string) (containertypes.ContainerCreateCreatedBody, error) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.ContainerCreateCreatedBody, error)
ContainerDiff(ctx context.Context, container string) ([]containertypes.ContainerChangeResponseItem, error) ContainerDiff(ctx context.Context, container string) ([]container.ContainerChangeResponseItem, error)
ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error) ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error) ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
@ -71,10 +71,10 @@ type ContainerAPIClient interface {
ContainerStatsOneShot(ctx context.Context, container string) (types.ContainerStats, error) ContainerStatsOneShot(ctx context.Context, container string) (types.ContainerStats, error)
ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error
ContainerStop(ctx context.Context, container string, timeout *time.Duration) error ContainerStop(ctx context.Context, container string, timeout *time.Duration) error
ContainerTop(ctx context.Context, container string, arguments []string) (containertypes.ContainerTopOKBody, error) ContainerTop(ctx context.Context, container string, arguments []string) (container.ContainerTopOKBody, error)
ContainerUnpause(ctx context.Context, container string) error ContainerUnpause(ctx context.Context, container string) error
ContainerUpdate(ctx context.Context, container string, updateConfig containertypes.UpdateConfig) (containertypes.ContainerUpdateOKBody, error) ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error)
ContainerWait(ctx context.Context, container string, condition containertypes.WaitCondition) (<-chan containertypes.ContainerWaitOKBody, <-chan error) ContainerWait(ctx context.Context, container string, condition container.WaitCondition) (<-chan container.ContainerWaitOKBody, <-chan error)
CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error
ContainersPrune(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error) ContainersPrune(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error)
@ -107,7 +107,7 @@ type ImageAPIClient interface {
// NetworkAPIClient defines API client methods for the networks // NetworkAPIClient defines API client methods for the networks
type NetworkAPIClient interface { type NetworkAPIClient interface {
NetworkConnect(ctx context.Context, network, container string, config *networktypes.EndpointSettings) error NetworkConnect(ctx context.Context, network, container string, config *network.EndpointSettings) error
NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error)
NetworkDisconnect(ctx context.Context, network, container string, force bool) error NetworkDisconnect(ctx context.Context, network, container string, force bool) error
NetworkInspect(ctx context.Context, network string, options types.NetworkInspectOptions) (types.NetworkResource, error) NetworkInspect(ctx context.Context, network string, options types.NetworkInspectOptions) (types.NetworkResource, error)
@ -174,10 +174,10 @@ type SystemAPIClient interface {
// VolumeAPIClient defines API client methods for the volumes // VolumeAPIClient defines API client methods for the volumes
type VolumeAPIClient interface { type VolumeAPIClient interface {
VolumeCreate(ctx context.Context, options volumetypes.VolumeCreateBody) (types.Volume, error) VolumeCreate(ctx context.Context, options volume.VolumeCreateBody) (types.Volume, error)
VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error)
VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error) VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error)
VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumeListOKBody, error) VolumeList(ctx context.Context, filter filters.Args) (volume.VolumeListOKBody, error)
VolumeRemove(ctx context.Context, volumeID string, force bool) error VolumeRemove(ctx context.Context, volumeID string, force bool) error
VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error) VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error)
} }

View File

@ -17,9 +17,9 @@ import (
"time" "time"
"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/container"
mounttypes "github.com/docker/docker/api/types/mount" "github.com/docker/docker/api/types/mount"
networktypes "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/versions"
"github.com/docker/docker/client" "github.com/docker/docker/client"
dconfig "github.com/docker/docker/daemon/config" dconfig "github.com/docker/docker/daemon/config"
@ -476,7 +476,7 @@ func (s *DockerSuite) TestContainerAPICommitWithLabelInConfig(c *testing.T) {
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
config := containertypes.Config{ config := container.Config{
Labels: map[string]string{"key1": "value1", "key2": "value2"}} Labels: map[string]string{"key1": "value1", "key2": "value2"}}
options := types.ContainerCommitOptions{ options := types.ContainerCommitOptions{
@ -504,12 +504,12 @@ func (s *DockerSuite) TestContainerAPIBadPort(c *testing.T) {
// TODO Windows to Windows CI - Port this test // TODO Windows to Windows CI - Port this test
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
Cmd: []string{"/bin/sh", "-c", "echo test"}, Cmd: []string{"/bin/sh", "-c", "echo test"},
} }
hostConfig := containertypes.HostConfig{ hostConfig := container.HostConfig{
PortBindings: nat.PortMap{ PortBindings: nat.PortMap{
"8080/tcp": []nat.PortBinding{ "8080/tcp": []nat.PortBinding{
{ {
@ -523,12 +523,12 @@ func (s *DockerSuite) TestContainerAPIBadPort(c *testing.T) {
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
_, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, nil, "") _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, nil, "")
assert.ErrorContains(c, err, `invalid port specification: "aa80"`) assert.ErrorContains(c, err, `invalid port specification: "aa80"`)
} }
func (s *DockerSuite) TestContainerAPICreate(c *testing.T) { func (s *DockerSuite) TestContainerAPICreate(c *testing.T) {
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
Cmd: []string{"/bin/sh", "-c", "touch /test && ls /test"}, Cmd: []string{"/bin/sh", "-c", "touch /test && ls /test"},
} }
@ -537,7 +537,7 @@ func (s *DockerSuite) TestContainerAPICreate(c *testing.T) {
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
container, err := cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, "") container, err := cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, "")
assert.NilError(c, err) assert.NilError(c, err)
out, _ := dockerCmd(c, "start", "-a", container.ID) out, _ := dockerCmd(c, "start", "-a", container.ID)
@ -550,7 +550,7 @@ func (s *DockerSuite) TestContainerAPICreateEmptyConfig(c *testing.T) {
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
_, err = cli.ContainerCreate(context.Background(), &containertypes.Config{}, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, "") _, err = cli.ContainerCreate(context.Background(), &container.Config{}, &container.HostConfig{}, &network.NetworkingConfig{}, nil, "")
expected := "No command specified" expected := "No command specified"
assert.ErrorContains(c, err, expected) assert.ErrorContains(c, err, expected)
@ -558,12 +558,12 @@ func (s *DockerSuite) TestContainerAPICreateEmptyConfig(c *testing.T) {
func (s *DockerSuite) TestContainerAPICreateMultipleNetworksConfig(c *testing.T) { func (s *DockerSuite) TestContainerAPICreateMultipleNetworksConfig(c *testing.T) {
// Container creation must fail if client specified configurations for more than one network // Container creation must fail if client specified configurations for more than one network
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
} }
networkingConfig := networktypes.NetworkingConfig{ networkingConfig := network.NetworkingConfig{
EndpointsConfig: map[string]*networktypes.EndpointSettings{ EndpointsConfig: map[string]*network.EndpointSettings{
"net1": {}, "net1": {},
"net2": {}, "net2": {},
"net3": {}, "net3": {},
@ -574,7 +574,7 @@ func (s *DockerSuite) TestContainerAPICreateMultipleNetworksConfig(c *testing.T)
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
_, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networkingConfig, nil, "") _, err = cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &networkingConfig, nil, "")
msg := err.Error() msg := err.Error()
// network name order in error message is not deterministic // network name order in error message is not deterministic
assert.Assert(c, strings.Contains(msg, "Container cannot be connected to network endpoints")) assert.Assert(c, strings.Contains(msg, "Container cannot be connected to network endpoints"))
@ -596,12 +596,12 @@ func (s *DockerSuite) TestContainerAPICreateOtherNetworkModes(c *testing.T) {
UtilCreateNetworkMode(c, "container:web1") UtilCreateNetworkMode(c, "container:web1")
} }
func UtilCreateNetworkMode(c *testing.T, networkMode containertypes.NetworkMode) { func UtilCreateNetworkMode(c *testing.T, networkMode container.NetworkMode) {
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
} }
hostConfig := containertypes.HostConfig{ hostConfig := container.HostConfig{
NetworkMode: networkMode, NetworkMode: networkMode,
} }
@ -609,7 +609,7 @@ func UtilCreateNetworkMode(c *testing.T, networkMode containertypes.NetworkMode)
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
container, err := cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, nil, "") container, err := cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, nil, "")
assert.NilError(c, err) assert.NilError(c, err)
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID) containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
@ -621,12 +621,12 @@ func UtilCreateNetworkMode(c *testing.T, networkMode containertypes.NetworkMode)
func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *testing.T) { func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *testing.T) {
// TODO Windows to Windows CI. The CpuShares part could be ported. // TODO Windows to Windows CI. The CpuShares part could be ported.
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
} }
hostConfig := containertypes.HostConfig{ hostConfig := container.HostConfig{
Resources: containertypes.Resources{ Resources: container.Resources{
CPUShares: 512, CPUShares: 512,
CpusetCpus: "0", CpusetCpus: "0",
}, },
@ -636,7 +636,7 @@ func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *testing.T) {
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
container, err := cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, nil, "") container, err := cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, nil, "")
assert.NilError(c, err) assert.NilError(c, err)
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID) containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
@ -938,7 +938,7 @@ func (s *DockerSuite) TestContainerAPIRestartNotimeoutParam(c *testing.T) {
func (s *DockerSuite) TestContainerAPIStart(c *testing.T) { func (s *DockerSuite) TestContainerAPIStart(c *testing.T) {
name := "testing-start" name := "testing-start"
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
Cmd: append([]string{"/bin/sh", "-c"}, sleepCommandForDaemonPlatform()...), Cmd: append([]string{"/bin/sh", "-c"}, sleepCommandForDaemonPlatform()...),
OpenStdin: true, OpenStdin: true,
@ -948,7 +948,7 @@ func (s *DockerSuite) TestContainerAPIStart(c *testing.T) {
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
_, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, name) _, err = cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, name)
assert.NilError(c, err) assert.NilError(c, err)
err = cli.ContainerStart(context.Background(), name, types.ContainerStartOptions{}) err = cli.ContainerStart(context.Background(), name, types.ContainerStartOptions{})
@ -1262,7 +1262,7 @@ func (s *DockerSuite) TestContainerAPIPostContainerStop(c *testing.T) {
// #14170 // #14170
func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *testing.T) { func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *testing.T) {
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
Entrypoint: []string{"echo"}, Entrypoint: []string{"echo"},
Cmd: []string{"hello", "world"}, Cmd: []string{"hello", "world"},
@ -1272,7 +1272,7 @@ func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *t
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
_, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, "echotest") _, err = cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, "echotest")
assert.NilError(c, err) assert.NilError(c, err)
out, _ := dockerCmd(c, "start", "-a", "echotest") out, _ := dockerCmd(c, "start", "-a", "echotest")
assert.Equal(c, strings.TrimSpace(out), "hello world") assert.Equal(c, strings.TrimSpace(out), "hello world")
@ -1290,7 +1290,7 @@ func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *t
// #14170 // #14170
func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *testing.T) { func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *testing.T) {
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
Cmd: []string{"echo", "hello", "world"}, Cmd: []string{"echo", "hello", "world"},
} }
@ -1299,7 +1299,7 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *testing.T)
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
_, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, "echotest") _, err = cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, "echotest")
assert.NilError(c, err) assert.NilError(c, err)
out, _ := dockerCmd(c, "start", "-a", "echotest") out, _ := dockerCmd(c, "start", "-a", "echotest")
assert.Equal(c, strings.TrimSpace(out), "hello world") assert.Equal(c, strings.TrimSpace(out), "hello world")
@ -1330,10 +1330,10 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *tes
assert.NilError(c, err) assert.NilError(c, err)
assert.Equal(c, res.StatusCode, http.StatusCreated) assert.Equal(c, res.StatusCode, http.StatusCreated)
config2 := containertypes.Config{ config2 := container.Config{
Image: "busybox", Image: "busybox",
} }
hostConfig := containertypes.HostConfig{ hostConfig := container.HostConfig{
CapAdd: []string{"net_admin", "SYS_ADMIN"}, CapAdd: []string{"net_admin", "SYS_ADMIN"},
CapDrop: []string{"SETGID", "CAP_SETPCAP"}, CapDrop: []string{"SETGID", "CAP_SETPCAP"},
} }
@ -1342,21 +1342,21 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *tes
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
_, err = cli.ContainerCreate(context.Background(), &config2, &hostConfig, &networktypes.NetworkingConfig{}, nil, "capaddtest1") _, err = cli.ContainerCreate(context.Background(), &config2, &hostConfig, &network.NetworkingConfig{}, nil, "capaddtest1")
assert.NilError(c, err) assert.NilError(c, err)
} }
// #14915 // #14915
func (s *DockerSuite) TestContainerAPICreateNoHostConfig118(c *testing.T) { func (s *DockerSuite) TestContainerAPICreateNoHostConfig118(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows only support 1.25 or later testRequires(c, DaemonIsLinux) // Windows only support 1.25 or later
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
} }
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion("v1.18")) cli, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion("v1.18"))
assert.NilError(c, err) assert.NilError(c, err)
_, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, "") _, err = cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, "")
assert.NilError(c, err) assert.NilError(c, err)
} }
@ -1397,27 +1397,27 @@ func (s *DockerSuite) TestPostContainersCreateWithWrongCpusetValues(c *testing.T
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
} }
hostConfig1 := containertypes.HostConfig{ hostConfig1 := container.HostConfig{
Resources: containertypes.Resources{ Resources: container.Resources{
CpusetCpus: "1-42,,", CpusetCpus: "1-42,,",
}, },
} }
name := "wrong-cpuset-cpus" name := "wrong-cpuset-cpus"
_, err = cli.ContainerCreate(context.Background(), &config, &hostConfig1, &networktypes.NetworkingConfig{}, nil, name) _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig1, &network.NetworkingConfig{}, nil, name)
expected := "Invalid value 1-42,, for cpuset cpus" expected := "Invalid value 1-42,, for cpuset cpus"
assert.ErrorContains(c, err, expected) assert.ErrorContains(c, err, expected)
hostConfig2 := containertypes.HostConfig{ hostConfig2 := container.HostConfig{
Resources: containertypes.Resources{ Resources: container.Resources{
CpusetMems: "42-3,1--", CpusetMems: "42-3,1--",
}, },
} }
name = "wrong-cpuset-mems" name = "wrong-cpuset-mems"
_, err = cli.ContainerCreate(context.Background(), &config, &hostConfig2, &networktypes.NetworkingConfig{}, nil, name) _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig2, &network.NetworkingConfig{}, nil, name)
expected = "Invalid value 42-3,1-- for cpuset mems" expected = "Invalid value 42-3,1-- for cpuset mems"
assert.ErrorContains(c, err, expected) assert.ErrorContains(c, err, expected)
} }
@ -1425,10 +1425,10 @@ func (s *DockerSuite) TestPostContainersCreateWithWrongCpusetValues(c *testing.T
func (s *DockerSuite) TestPostContainersCreateShmSizeNegative(c *testing.T) { func (s *DockerSuite) TestPostContainersCreateShmSizeNegative(c *testing.T) {
// ShmSize is not supported on Windows // ShmSize is not supported on Windows
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
} }
hostConfig := containertypes.HostConfig{ hostConfig := container.HostConfig{
ShmSize: -1, ShmSize: -1,
} }
@ -1436,7 +1436,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeNegative(c *testing.T) {
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
_, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, nil, "") _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, nil, "")
assert.ErrorContains(c, err, "SHM size can not be less than 0") assert.ErrorContains(c, err, "SHM size can not be less than 0")
} }
@ -1444,7 +1444,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *testin
// ShmSize is not supported on Windows // ShmSize is not supported on Windows
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
Cmd: []string{"mount"}, Cmd: []string{"mount"},
} }
@ -1453,7 +1453,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *testin
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
container, err := cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, "") container, err := cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, "")
assert.NilError(c, err) assert.NilError(c, err)
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID) containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
@ -1471,7 +1471,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *testin
func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *testing.T) { func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *testing.T) {
// ShmSize is not supported on Windows // ShmSize is not supported on Windows
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
Cmd: []string{"mount"}, Cmd: []string{"mount"},
} }
@ -1480,7 +1480,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *testing.T) {
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
container, err := cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, "") container, err := cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, "")
assert.NilError(c, err) assert.NilError(c, err)
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID) containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
@ -1498,12 +1498,12 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *testing.T) {
func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *testing.T) { func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *testing.T) {
// ShmSize is not supported on Windows // ShmSize is not supported on Windows
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
Cmd: []string{"mount"}, Cmd: []string{"mount"},
} }
hostConfig := containertypes.HostConfig{ hostConfig := container.HostConfig{
ShmSize: 1073741824, ShmSize: 1073741824,
} }
@ -1511,7 +1511,7 @@ func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *testing.T) {
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
container, err := cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, nil, "") container, err := cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, nil, "")
assert.NilError(c, err) assert.NilError(c, err)
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID) containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
@ -1529,7 +1529,7 @@ func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *testing.T) {
func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(c *testing.T) { func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(c *testing.T) {
// Swappiness is not supported on Windows // Swappiness is not supported on Windows
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
} }
@ -1537,7 +1537,7 @@ func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
container, err := cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, "") container, err := cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, "")
assert.NilError(c, err) assert.NilError(c, err)
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID) containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
@ -1555,11 +1555,11 @@ func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *tes
// OomScoreAdj is not supported on Windows // OomScoreAdj is not supported on Windows
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
} }
hostConfig := containertypes.HostConfig{ hostConfig := container.HostConfig{
OomScoreAdj: 1001, OomScoreAdj: 1001,
} }
@ -1568,17 +1568,17 @@ func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *tes
defer cli.Close() defer cli.Close()
name := "oomscoreadj-over" name := "oomscoreadj-over"
_, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, nil, name) _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, nil, name)
expected := "Invalid value 1001, range for oom score adj is [-1000, 1000]" expected := "Invalid value 1001, range for oom score adj is [-1000, 1000]"
assert.ErrorContains(c, err, expected) assert.ErrorContains(c, err, expected)
hostConfig = containertypes.HostConfig{ hostConfig = container.HostConfig{
OomScoreAdj: -1001, OomScoreAdj: -1001,
} }
name = "oomscoreadj-low" name = "oomscoreadj-low"
_, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, nil, name) _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, nil, name)
expected = "Invalid value -1001, range for oom score adj is [-1000, 1000]" expected = "Invalid value -1001, range for oom score adj is [-1000, 1000]"
assert.ErrorContains(c, err, expected) assert.ErrorContains(c, err, expected)
@ -1600,7 +1600,7 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) {
name := "testing-network-disabled" name := "testing-network-disabled"
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
Cmd: []string{"top"}, Cmd: []string{"top"},
NetworkDisabled: true, NetworkDisabled: true,
@ -1610,7 +1610,7 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) {
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
_, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, name) _, err = cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, name)
assert.NilError(c, err) assert.NilError(c, err)
err = cli.ContainerStart(context.Background(), name, types.ContainerStartOptions{}) err = cli.ContainerStart(context.Background(), name, types.ContainerStartOptions{})
@ -1645,8 +1645,8 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) {
func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) { func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
type testCase struct { type testCase struct {
config containertypes.Config config container.Config
hostConfig containertypes.HostConfig hostConfig container.HostConfig
msg string msg string
} }
@ -1656,11 +1656,11 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
cases := []testCase{ cases := []testCase{
{ {
config: containertypes.Config{ config: container.Config{
Image: "busybox", Image: "busybox",
}, },
hostConfig: containertypes.HostConfig{ hostConfig: container.HostConfig{
Mounts: []mounttypes.Mount{{ Mounts: []mount.Mount{{
Type: "notreal", Type: "notreal",
Target: destPath, Target: destPath,
}, },
@ -1670,30 +1670,30 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
msg: "mount type unknown", msg: "mount type unknown",
}, },
{ {
config: containertypes.Config{ config: container.Config{
Image: "busybox", Image: "busybox",
}, },
hostConfig: containertypes.HostConfig{ hostConfig: container.HostConfig{
Mounts: []mounttypes.Mount{{ Mounts: []mount.Mount{{
Type: "bind"}}}, Type: "bind"}}},
msg: "Target must not be empty", msg: "Target must not be empty",
}, },
{ {
config: containertypes.Config{ config: container.Config{
Image: "busybox", Image: "busybox",
}, },
hostConfig: containertypes.HostConfig{ hostConfig: container.HostConfig{
Mounts: []mounttypes.Mount{{ Mounts: []mount.Mount{{
Type: "bind", Type: "bind",
Target: destPath}}}, Target: destPath}}},
msg: "Source must not be empty", msg: "Source must not be empty",
}, },
{ {
config: containertypes.Config{ config: container.Config{
Image: "busybox", Image: "busybox",
}, },
hostConfig: containertypes.HostConfig{ hostConfig: container.HostConfig{
Mounts: []mounttypes.Mount{{ Mounts: []mount.Mount{{
Type: "bind", Type: "bind",
Source: notExistPath, Source: notExistPath,
Target: destPath}}}, Target: destPath}}},
@ -1702,36 +1702,36 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
// msg: "source path does not exist: " + notExistPath, // msg: "source path does not exist: " + notExistPath,
}, },
{ {
config: containertypes.Config{ config: container.Config{
Image: "busybox", Image: "busybox",
}, },
hostConfig: containertypes.HostConfig{ hostConfig: container.HostConfig{
Mounts: []mounttypes.Mount{{ Mounts: []mount.Mount{{
Type: "volume"}}}, Type: "volume"}}},
msg: "Target must not be empty", msg: "Target must not be empty",
}, },
{ {
config: containertypes.Config{ config: container.Config{
Image: "busybox", Image: "busybox",
}, },
hostConfig: containertypes.HostConfig{ hostConfig: container.HostConfig{
Mounts: []mounttypes.Mount{{ Mounts: []mount.Mount{{
Type: "volume", Type: "volume",
Source: "hello", Source: "hello",
Target: destPath}}}, Target: destPath}}},
msg: "", msg: "",
}, },
{ {
config: containertypes.Config{ config: container.Config{
Image: "busybox", Image: "busybox",
}, },
hostConfig: containertypes.HostConfig{ hostConfig: container.HostConfig{
Mounts: []mounttypes.Mount{{ Mounts: []mount.Mount{{
Type: "volume", Type: "volume",
Source: "hello2", Source: "hello2",
Target: destPath, Target: destPath,
VolumeOptions: &mounttypes.VolumeOptions{ VolumeOptions: &mount.VolumeOptions{
DriverConfig: &mounttypes.Driver{ DriverConfig: &mount.Driver{
Name: "local"}}}}}, Name: "local"}}}}},
msg: "", msg: "",
}, },
@ -1743,26 +1743,26 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
cases = append(cases, []testCase{ cases = append(cases, []testCase{
{ {
config: containertypes.Config{ config: container.Config{
Image: "busybox", Image: "busybox",
}, },
hostConfig: containertypes.HostConfig{ hostConfig: container.HostConfig{
Mounts: []mounttypes.Mount{{ Mounts: []mount.Mount{{
Type: "bind", Type: "bind",
Source: tmpDir, Source: tmpDir,
Target: destPath}}}, Target: destPath}}},
msg: "", msg: "",
}, },
{ {
config: containertypes.Config{ config: container.Config{
Image: "busybox", Image: "busybox",
}, },
hostConfig: containertypes.HostConfig{ hostConfig: container.HostConfig{
Mounts: []mounttypes.Mount{{ Mounts: []mount.Mount{{
Type: "bind", Type: "bind",
Source: tmpDir, Source: tmpDir,
Target: destPath, Target: destPath,
VolumeOptions: &mounttypes.VolumeOptions{}}}}, VolumeOptions: &mount.VolumeOptions{}}}},
msg: "VolumeOptions must not be specified", msg: "VolumeOptions must not be specified",
}, },
}...) }...)
@ -1771,17 +1771,17 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
if DaemonIsWindows() { if DaemonIsWindows() {
cases = append(cases, []testCase{ cases = append(cases, []testCase{
{ {
config: containertypes.Config{ config: container.Config{
Image: "busybox", Image: "busybox",
}, },
hostConfig: containertypes.HostConfig{ hostConfig: container.HostConfig{
Mounts: []mounttypes.Mount{ Mounts: []mount.Mount{
{ {
Type: "volume", Type: "volume",
Source: "not-supported-on-windows", Source: "not-supported-on-windows",
Target: destPath, Target: destPath,
VolumeOptions: &mounttypes.VolumeOptions{ VolumeOptions: &mount.VolumeOptions{
DriverConfig: &mounttypes.Driver{ DriverConfig: &mount.Driver{
Name: "local", Name: "local",
Options: map[string]string{"type": "tmpfs"}, Options: map[string]string{"type": "tmpfs"},
}, },
@ -1797,17 +1797,17 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
if DaemonIsLinux() { if DaemonIsLinux() {
cases = append(cases, []testCase{ cases = append(cases, []testCase{
{ {
config: containertypes.Config{ config: container.Config{
Image: "busybox", Image: "busybox",
}, },
hostConfig: containertypes.HostConfig{ hostConfig: container.HostConfig{
Mounts: []mounttypes.Mount{ Mounts: []mount.Mount{
{ {
Type: "volume", Type: "volume",
Source: "missing-device-opt", Source: "missing-device-opt",
Target: destPath, Target: destPath,
VolumeOptions: &mounttypes.VolumeOptions{ VolumeOptions: &mount.VolumeOptions{
DriverConfig: &mounttypes.Driver{ DriverConfig: &mount.Driver{
Name: "local", Name: "local",
Options: map[string]string{"foobar": "foobaz"}, Options: map[string]string{"foobar": "foobaz"},
}, },
@ -1818,17 +1818,17 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
msg: `invalid option: "foobar"`, msg: `invalid option: "foobar"`,
}, },
{ {
config: containertypes.Config{ config: container.Config{
Image: "busybox", Image: "busybox",
}, },
hostConfig: containertypes.HostConfig{ hostConfig: container.HostConfig{
Mounts: []mounttypes.Mount{ Mounts: []mount.Mount{
{ {
Type: "volume", Type: "volume",
Source: "missing-device-opt", Source: "missing-device-opt",
Target: destPath, Target: destPath,
VolumeOptions: &mounttypes.VolumeOptions{ VolumeOptions: &mount.VolumeOptions{
DriverConfig: &mounttypes.Driver{ DriverConfig: &mount.Driver{
Name: "local", Name: "local",
Options: map[string]string{"type": "tmpfs"}, Options: map[string]string{"type": "tmpfs"},
}, },
@ -1839,17 +1839,17 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
msg: `missing required option: "device"`, msg: `missing required option: "device"`,
}, },
{ {
config: containertypes.Config{ config: container.Config{
Image: "busybox", Image: "busybox",
}, },
hostConfig: containertypes.HostConfig{ hostConfig: container.HostConfig{
Mounts: []mounttypes.Mount{ Mounts: []mount.Mount{
{ {
Type: "volume", Type: "volume",
Source: "missing-type-opt", Source: "missing-type-opt",
Target: destPath, Target: destPath,
VolumeOptions: &mounttypes.VolumeOptions{ VolumeOptions: &mount.VolumeOptions{
DriverConfig: &mounttypes.Driver{ DriverConfig: &mount.Driver{
Name: "local", Name: "local",
Options: map[string]string{"device": "tmpfs"}, Options: map[string]string{"device": "tmpfs"},
}, },
@ -1860,17 +1860,17 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
msg: `missing required option: "type"`, msg: `missing required option: "type"`,
}, },
{ {
config: containertypes.Config{ config: container.Config{
Image: "busybox", Image: "busybox",
}, },
hostConfig: containertypes.HostConfig{ hostConfig: container.HostConfig{
Mounts: []mounttypes.Mount{ Mounts: []mount.Mount{
{ {
Type: "volume", Type: "volume",
Source: "hello4", Source: "hello4",
Target: destPath, Target: destPath,
VolumeOptions: &mounttypes.VolumeOptions{ VolumeOptions: &mount.VolumeOptions{
DriverConfig: &mounttypes.Driver{ DriverConfig: &mount.Driver{
Name: "local", Name: "local",
Options: map[string]string{"o": "size=1", "type": "tmpfs", "device": "tmpfs"}, Options: map[string]string{"o": "size=1", "type": "tmpfs", "device": "tmpfs"},
}, },
@ -1881,35 +1881,35 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
msg: "", msg: "",
}, },
{ {
config: containertypes.Config{ config: container.Config{
Image: "busybox", Image: "busybox",
}, },
hostConfig: containertypes.HostConfig{ hostConfig: container.HostConfig{
Mounts: []mounttypes.Mount{{ Mounts: []mount.Mount{{
Type: "tmpfs", Type: "tmpfs",
Target: destPath}}}, Target: destPath}}},
msg: "", msg: "",
}, },
{ {
config: containertypes.Config{ config: container.Config{
Image: "busybox", Image: "busybox",
}, },
hostConfig: containertypes.HostConfig{ hostConfig: container.HostConfig{
Mounts: []mounttypes.Mount{{ Mounts: []mount.Mount{{
Type: "tmpfs", Type: "tmpfs",
Target: destPath, Target: destPath,
TmpfsOptions: &mounttypes.TmpfsOptions{ TmpfsOptions: &mount.TmpfsOptions{
SizeBytes: 4096 * 1024, SizeBytes: 4096 * 1024,
Mode: 0700, Mode: 0700,
}}}}, }}}},
msg: "", msg: "",
}, },
{ {
config: containertypes.Config{ config: container.Config{
Image: "busybox", Image: "busybox",
}, },
hostConfig: containertypes.HostConfig{ hostConfig: container.HostConfig{
Mounts: []mounttypes.Mount{{ Mounts: []mount.Mount{{
Type: "tmpfs", Type: "tmpfs",
Source: "/shouldnotbespecified", Source: "/shouldnotbespecified",
Target: destPath}}}, Target: destPath}}},
@ -1926,7 +1926,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
for i, x := range cases { for i, x := range cases {
x := x x := x
c.Run(fmt.Sprintf("case %d", i), func(c *testing.T) { c.Run(fmt.Sprintf("case %d", i), func(c *testing.T) {
_, err = apiClient.ContainerCreate(context.Background(), &x.config, &x.hostConfig, &networktypes.NetworkingConfig{}, nil, "") _, err = apiClient.ContainerCreate(context.Background(), &x.config, &x.hostConfig, &network.NetworkingConfig{}, nil, "")
if len(x.msg) > 0 { if len(x.msg) > 0 {
assert.ErrorContains(c, err, x.msg, "%v", cases[i].config) assert.ErrorContains(c, err, x.msg, "%v", cases[i].config)
} else { } else {
@ -1946,12 +1946,12 @@ func (s *DockerSuite) TestContainerAPICreateMountsBindRead(c *testing.T) {
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
err = os.WriteFile(filepath.Join(tmpDir, "bar"), []byte("hello"), 0666) err = os.WriteFile(filepath.Join(tmpDir, "bar"), []byte("hello"), 0666)
assert.NilError(c, err) assert.NilError(c, err)
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
Cmd: []string{"/bin/sh", "-c", "cat /foo/bar"}, Cmd: []string{"/bin/sh", "-c", "cat /foo/bar"},
} }
hostConfig := containertypes.HostConfig{ hostConfig := container.HostConfig{
Mounts: []mounttypes.Mount{ Mounts: []mount.Mount{
{Type: "bind", Source: tmpDir, Target: destPath}, {Type: "bind", Source: tmpDir, Target: destPath},
}, },
} }
@ -1959,7 +1959,7 @@ func (s *DockerSuite) TestContainerAPICreateMountsBindRead(c *testing.T) {
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
_, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, nil, "test") _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, nil, "test")
assert.NilError(c, err) assert.NilError(c, err)
out, _ := dockerCmd(c, "start", "-a", "test") out, _ := dockerCmd(c, "start", "-a", "test")
@ -1986,7 +1986,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
} }
type testCase struct { type testCase struct {
spec mounttypes.Mount spec mount.Mount
expected types.MountPoint expected types.MountPoint
} }
@ -2004,23 +2004,23 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
// use literal strings here for `Type` instead of the defined constants in the volume package to keep this honest // use literal strings here for `Type` instead of the defined constants in the volume package to keep this honest
// Validation of the actual `Mount` struct is done in another test is not needed here // Validation of the actual `Mount` struct is done in another test is not needed here
{ {
spec: mounttypes.Mount{Type: "volume", Target: destPath}, spec: mount.Mount{Type: "volume", Target: destPath},
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel}, expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
}, },
{ {
spec: mounttypes.Mount{Type: "volume", Target: destPath + slash}, spec: mount.Mount{Type: "volume", Target: destPath + slash},
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel}, expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
}, },
{ {
spec: mounttypes.Mount{Type: "volume", Target: destPath, Source: "test1"}, spec: mount.Mount{Type: "volume", Target: destPath, Source: "test1"},
expected: types.MountPoint{Type: "volume", Name: "test1", RW: true, Destination: destPath, Mode: selinuxSharedLabel}, expected: types.MountPoint{Type: "volume", Name: "test1", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
}, },
{ {
spec: mounttypes.Mount{Type: "volume", Target: destPath, ReadOnly: true, Source: "test2"}, spec: mount.Mount{Type: "volume", Target: destPath, ReadOnly: true, Source: "test2"},
expected: types.MountPoint{Type: "volume", Name: "test2", RW: false, Destination: destPath, Mode: selinuxSharedLabel}, expected: types.MountPoint{Type: "volume", Name: "test2", RW: false, Destination: destPath, Mode: selinuxSharedLabel},
}, },
{ {
spec: mounttypes.Mount{Type: "volume", Target: destPath, Source: "test3", VolumeOptions: &mounttypes.VolumeOptions{DriverConfig: &mounttypes.Driver{Name: volume.DefaultDriverName}}}, spec: mount.Mount{Type: "volume", Target: destPath, Source: "test3", VolumeOptions: &mount.VolumeOptions{DriverConfig: &mount.Driver{Name: volume.DefaultDriverName}}},
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", Name: "test3", RW: true, Destination: destPath, Mode: selinuxSharedLabel}, expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", Name: "test3", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
}, },
} }
@ -2032,7 +2032,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
defer os.RemoveAll(tmpDir1) defer os.RemoveAll(tmpDir1)
cases = append(cases, []testCase{ cases = append(cases, []testCase{
{ {
spec: mounttypes.Mount{ spec: mount.Mount{
Type: "bind", Type: "bind",
Source: tmpDir1, Source: tmpDir1,
Target: destPath, Target: destPath,
@ -2045,7 +2045,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
}, },
}, },
{ {
spec: mounttypes.Mount{Type: "bind", Source: tmpDir1, Target: destPath, ReadOnly: true}, spec: mount.Mount{Type: "bind", Source: tmpDir1, Target: destPath, ReadOnly: true},
expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir1}, expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir1},
}, },
}...) }...)
@ -2060,15 +2060,15 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
cases = append(cases, []testCase{ cases = append(cases, []testCase{
{ {
spec: mounttypes.Mount{Type: "bind", Source: tmpDir3, Target: destPath}, spec: mount.Mount{Type: "bind", Source: tmpDir3, Target: destPath},
expected: types.MountPoint{Type: "bind", RW: true, Destination: destPath, Source: tmpDir3}, expected: types.MountPoint{Type: "bind", RW: true, Destination: destPath, Source: tmpDir3},
}, },
{ {
spec: mounttypes.Mount{Type: "bind", Source: tmpDir3, Target: destPath, ReadOnly: true}, spec: mount.Mount{Type: "bind", Source: tmpDir3, Target: destPath, ReadOnly: true},
expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3}, expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3},
}, },
{ {
spec: mounttypes.Mount{Type: "bind", Source: tmpDir3, Target: destPath, ReadOnly: true, BindOptions: &mounttypes.BindOptions{Propagation: "shared"}}, spec: mount.Mount{Type: "bind", Source: tmpDir3, Target: destPath, ReadOnly: true, BindOptions: &mount.BindOptions{Propagation: "shared"}},
expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3, Propagation: "shared"}, expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3, Propagation: "shared"},
}, },
}...) }...)
@ -2078,19 +2078,19 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
if testEnv.OSType != "windows" { // Windows does not support volume populate if testEnv.OSType != "windows" { // Windows does not support volume populate
cases = append(cases, []testCase{ cases = append(cases, []testCase{
{ {
spec: mounttypes.Mount{Type: "volume", Target: destPath, VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}}, spec: mount.Mount{Type: "volume", Target: destPath, VolumeOptions: &mount.VolumeOptions{NoCopy: true}},
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel}, expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
}, },
{ {
spec: mounttypes.Mount{Type: "volume", Target: destPath + slash, VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}}, spec: mount.Mount{Type: "volume", Target: destPath + slash, VolumeOptions: &mount.VolumeOptions{NoCopy: true}},
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel}, expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
}, },
{ {
spec: mounttypes.Mount{Type: "volume", Target: destPath, Source: "test4", VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}}, spec: mount.Mount{Type: "volume", Target: destPath, Source: "test4", VolumeOptions: &mount.VolumeOptions{NoCopy: true}},
expected: types.MountPoint{Type: "volume", Name: "test4", RW: true, Destination: destPath, Mode: selinuxSharedLabel}, expected: types.MountPoint{Type: "volume", Name: "test4", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
}, },
{ {
spec: mounttypes.Mount{Type: "volume", Target: destPath, Source: "test5", ReadOnly: true, VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}}, spec: mount.Mount{Type: "volume", Target: destPath, Source: "test5", ReadOnly: true, VolumeOptions: &mount.VolumeOptions{NoCopy: true}},
expected: types.MountPoint{Type: "volume", Name: "test5", RW: false, Destination: destPath, Mode: selinuxSharedLabel}, expected: types.MountPoint{Type: "volume", Name: "test5", RW: false, Destination: destPath, Mode: selinuxSharedLabel},
}, },
}...) }...)
@ -2103,9 +2103,9 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
c.Run(fmt.Sprintf("%d config: %v", i, x.spec), func(c *testing.T) { c.Run(fmt.Sprintf("%d config: %v", i, x.spec), func(c *testing.T) {
container, err := apiclient.ContainerCreate( container, err := apiclient.ContainerCreate(
ctx, ctx,
&containertypes.Config{Image: testImg}, &container.Config{Image: testImg},
&containertypes.HostConfig{Mounts: []mounttypes.Mount{x.spec}}, &container.HostConfig{Mounts: []mount.Mount{x.spec}},
&networktypes.NetworkingConfig{}, &network.NetworkingConfig{},
nil, nil,
"") "")
assert.NilError(c, err) assert.NilError(c, err)
@ -2179,22 +2179,22 @@ func containerExit(apiclient client.APIClient, name string) func(poll.LogT) poll
func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *testing.T) { func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
type testCase struct { type testCase struct {
cfg mounttypes.Mount cfg mount.Mount
expectedOptions []string expectedOptions []string
} }
target := "/foo" target := "/foo"
cases := []testCase{ cases := []testCase{
{ {
cfg: mounttypes.Mount{ cfg: mount.Mount{
Type: "tmpfs", Type: "tmpfs",
Target: target}, Target: target},
expectedOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime"}, expectedOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime"},
}, },
{ {
cfg: mounttypes.Mount{ cfg: mount.Mount{
Type: "tmpfs", Type: "tmpfs",
Target: target, Target: target,
TmpfsOptions: &mounttypes.TmpfsOptions{ TmpfsOptions: &mount.TmpfsOptions{
SizeBytes: 4096 * 1024, Mode: 0700}}, SizeBytes: 4096 * 1024, Mode: 0700}},
expectedOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime", "size=4096k", "mode=700"}, expectedOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime", "size=4096k", "mode=700"},
}, },
@ -2204,17 +2204,17 @@ func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *testing.T) {
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
config := containertypes.Config{ config := container.Config{
Image: "busybox", Image: "busybox",
Cmd: []string{"/bin/sh", "-c", fmt.Sprintf("mount | grep 'tmpfs on %s'", target)}, Cmd: []string{"/bin/sh", "-c", fmt.Sprintf("mount | grep 'tmpfs on %s'", target)},
} }
for i, x := range cases { for i, x := range cases {
cName := fmt.Sprintf("test-tmpfs-%d", i) cName := fmt.Sprintf("test-tmpfs-%d", i)
hostConfig := containertypes.HostConfig{ hostConfig := container.HostConfig{
Mounts: []mounttypes.Mount{x.cfg}, Mounts: []mount.Mount{x.cfg},
} }
_, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, nil, cName) _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, nil, cName)
assert.NilError(c, err) assert.NilError(c, err)
out, _ := dockerCmd(c, "start", "-a", cName) out, _ := dockerCmd(c, "start", "-a", cName)
for _, option := range x.expectedOptions { for _, option := range x.expectedOptions {