client, integration-cli: remove unneeded import aliases
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
83a185897d
commit
9060126639
2 changed files with 168 additions and 168 deletions
|
@ -8,14 +8,14 @@ import (
|
|||
"time"
|
||||
|
||||
"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/filters"
|
||||
"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/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"
|
||||
)
|
||||
|
||||
|
@ -48,8 +48,8 @@ type CommonAPIClient interface {
|
|||
type ContainerAPIClient interface {
|
||||
ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, 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)
|
||||
ContainerDiff(ctx context.Context, container string) ([]containertypes.ContainerChangeResponseItem, 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) ([]container.ContainerChangeResponseItem, 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)
|
||||
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)
|
||||
ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) 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
|
||||
ContainerUpdate(ctx context.Context, container string, updateConfig containertypes.UpdateConfig) (containertypes.ContainerUpdateOKBody, error)
|
||||
ContainerWait(ctx context.Context, container string, condition containertypes.WaitCondition) (<-chan containertypes.ContainerWaitOKBody, <-chan error)
|
||||
ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, 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)
|
||||
CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) 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
|
||||
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)
|
||||
NetworkDisconnect(ctx context.Context, network, container string, force bool) 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
|
||||
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)
|
||||
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
|
||||
VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error)
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
containertypes "github.com/docker/docker/api/types/container"
|
||||
mounttypes "github.com/docker/docker/api/types/mount"
|
||||
networktypes "github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/mount"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/docker/api/types/versions"
|
||||
"github.com/docker/docker/client"
|
||||
dconfig "github.com/docker/docker/daemon/config"
|
||||
|
@ -476,7 +476,7 @@ func (s *DockerSuite) TestContainerAPICommitWithLabelInConfig(c *testing.T) {
|
|||
assert.NilError(c, err)
|
||||
defer cli.Close()
|
||||
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Labels: map[string]string{"key1": "value1", "key2": "value2"}}
|
||||
|
||||
options := types.ContainerCommitOptions{
|
||||
|
@ -504,12 +504,12 @@ func (s *DockerSuite) TestContainerAPIBadPort(c *testing.T) {
|
|||
// TODO Windows to Windows CI - Port this test
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
Cmd: []string{"/bin/sh", "-c", "echo test"},
|
||||
}
|
||||
|
||||
hostConfig := containertypes.HostConfig{
|
||||
hostConfig := container.HostConfig{
|
||||
PortBindings: nat.PortMap{
|
||||
"8080/tcp": []nat.PortBinding{
|
||||
{
|
||||
|
@ -523,12 +523,12 @@ func (s *DockerSuite) TestContainerAPIBadPort(c *testing.T) {
|
|||
assert.NilError(c, err)
|
||||
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"`)
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerAPICreate(c *testing.T) {
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
Cmd: []string{"/bin/sh", "-c", "touch /test && ls /test"},
|
||||
}
|
||||
|
@ -537,7 +537,7 @@ func (s *DockerSuite) TestContainerAPICreate(c *testing.T) {
|
|||
assert.NilError(c, err)
|
||||
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)
|
||||
|
||||
out, _ := dockerCmd(c, "start", "-a", container.ID)
|
||||
|
@ -550,7 +550,7 @@ func (s *DockerSuite) TestContainerAPICreateEmptyConfig(c *testing.T) {
|
|||
assert.NilError(c, err)
|
||||
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"
|
||||
assert.ErrorContains(c, err, expected)
|
||||
|
@ -558,12 +558,12 @@ func (s *DockerSuite) TestContainerAPICreateEmptyConfig(c *testing.T) {
|
|||
|
||||
func (s *DockerSuite) TestContainerAPICreateMultipleNetworksConfig(c *testing.T) {
|
||||
// Container creation must fail if client specified configurations for more than one network
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
}
|
||||
|
||||
networkingConfig := networktypes.NetworkingConfig{
|
||||
EndpointsConfig: map[string]*networktypes.EndpointSettings{
|
||||
networkingConfig := network.NetworkingConfig{
|
||||
EndpointsConfig: map[string]*network.EndpointSettings{
|
||||
"net1": {},
|
||||
"net2": {},
|
||||
"net3": {},
|
||||
|
@ -574,7 +574,7 @@ func (s *DockerSuite) TestContainerAPICreateMultipleNetworksConfig(c *testing.T)
|
|||
assert.NilError(c, err)
|
||||
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()
|
||||
// network name order in error message is not deterministic
|
||||
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")
|
||||
}
|
||||
|
||||
func UtilCreateNetworkMode(c *testing.T, networkMode containertypes.NetworkMode) {
|
||||
config := containertypes.Config{
|
||||
func UtilCreateNetworkMode(c *testing.T, networkMode container.NetworkMode) {
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
}
|
||||
|
||||
hostConfig := containertypes.HostConfig{
|
||||
hostConfig := container.HostConfig{
|
||||
NetworkMode: networkMode,
|
||||
}
|
||||
|
||||
|
@ -609,7 +609,7 @@ func UtilCreateNetworkMode(c *testing.T, networkMode containertypes.NetworkMode)
|
|||
assert.NilError(c, err)
|
||||
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)
|
||||
|
||||
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) {
|
||||
// TODO Windows to Windows CI. The CpuShares part could be ported.
|
||||
testRequires(c, DaemonIsLinux)
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
}
|
||||
|
||||
hostConfig := containertypes.HostConfig{
|
||||
Resources: containertypes.Resources{
|
||||
hostConfig := container.HostConfig{
|
||||
Resources: container.Resources{
|
||||
CPUShares: 512,
|
||||
CpusetCpus: "0",
|
||||
},
|
||||
|
@ -636,7 +636,7 @@ func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *testing.T) {
|
|||
assert.NilError(c, err)
|
||||
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)
|
||||
|
||||
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) {
|
||||
name := "testing-start"
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
Cmd: append([]string{"/bin/sh", "-c"}, sleepCommandForDaemonPlatform()...),
|
||||
OpenStdin: true,
|
||||
|
@ -948,7 +948,7 @@ func (s *DockerSuite) TestContainerAPIStart(c *testing.T) {
|
|||
assert.NilError(c, err)
|
||||
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)
|
||||
|
||||
err = cli.ContainerStart(context.Background(), name, types.ContainerStartOptions{})
|
||||
|
@ -1262,7 +1262,7 @@ func (s *DockerSuite) TestContainerAPIPostContainerStop(c *testing.T) {
|
|||
|
||||
// #14170
|
||||
func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *testing.T) {
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
Entrypoint: []string{"echo"},
|
||||
Cmd: []string{"hello", "world"},
|
||||
|
@ -1272,7 +1272,7 @@ func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *t
|
|||
assert.NilError(c, err)
|
||||
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)
|
||||
out, _ := dockerCmd(c, "start", "-a", "echotest")
|
||||
assert.Equal(c, strings.TrimSpace(out), "hello world")
|
||||
|
@ -1290,7 +1290,7 @@ func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *t
|
|||
|
||||
// #14170
|
||||
func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *testing.T) {
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
Cmd: []string{"echo", "hello", "world"},
|
||||
}
|
||||
|
@ -1299,7 +1299,7 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *testing.T)
|
|||
assert.NilError(c, err)
|
||||
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)
|
||||
out, _ := dockerCmd(c, "start", "-a", "echotest")
|
||||
assert.Equal(c, strings.TrimSpace(out), "hello world")
|
||||
|
@ -1330,10 +1330,10 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *tes
|
|||
assert.NilError(c, err)
|
||||
assert.Equal(c, res.StatusCode, http.StatusCreated)
|
||||
|
||||
config2 := containertypes.Config{
|
||||
config2 := container.Config{
|
||||
Image: "busybox",
|
||||
}
|
||||
hostConfig := containertypes.HostConfig{
|
||||
hostConfig := container.HostConfig{
|
||||
CapAdd: []string{"net_admin", "SYS_ADMIN"},
|
||||
CapDrop: []string{"SETGID", "CAP_SETPCAP"},
|
||||
}
|
||||
|
@ -1342,21 +1342,21 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *tes
|
|||
assert.NilError(c, err)
|
||||
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)
|
||||
}
|
||||
|
||||
// #14915
|
||||
func (s *DockerSuite) TestContainerAPICreateNoHostConfig118(c *testing.T) {
|
||||
testRequires(c, DaemonIsLinux) // Windows only support 1.25 or later
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
}
|
||||
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion("v1.18"))
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -1397,27 +1397,27 @@ func (s *DockerSuite) TestPostContainersCreateWithWrongCpusetValues(c *testing.T
|
|||
assert.NilError(c, err)
|
||||
defer cli.Close()
|
||||
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
}
|
||||
hostConfig1 := containertypes.HostConfig{
|
||||
Resources: containertypes.Resources{
|
||||
hostConfig1 := container.HostConfig{
|
||||
Resources: container.Resources{
|
||||
CpusetCpus: "1-42,,",
|
||||
},
|
||||
}
|
||||
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"
|
||||
assert.ErrorContains(c, err, expected)
|
||||
|
||||
hostConfig2 := containertypes.HostConfig{
|
||||
Resources: containertypes.Resources{
|
||||
hostConfig2 := container.HostConfig{
|
||||
Resources: container.Resources{
|
||||
CpusetMems: "42-3,1--",
|
||||
},
|
||||
}
|
||||
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"
|
||||
assert.ErrorContains(c, err, expected)
|
||||
}
|
||||
|
@ -1425,10 +1425,10 @@ func (s *DockerSuite) TestPostContainersCreateWithWrongCpusetValues(c *testing.T
|
|||
func (s *DockerSuite) TestPostContainersCreateShmSizeNegative(c *testing.T) {
|
||||
// ShmSize is not supported on Windows
|
||||
testRequires(c, DaemonIsLinux)
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
}
|
||||
hostConfig := containertypes.HostConfig{
|
||||
hostConfig := container.HostConfig{
|
||||
ShmSize: -1,
|
||||
}
|
||||
|
||||
|
@ -1436,7 +1436,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeNegative(c *testing.T) {
|
|||
assert.NilError(c, err)
|
||||
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")
|
||||
}
|
||||
|
||||
|
@ -1444,7 +1444,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *testin
|
|||
// ShmSize is not supported on Windows
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
Cmd: []string{"mount"},
|
||||
}
|
||||
|
@ -1453,7 +1453,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *testin
|
|||
assert.NilError(c, err)
|
||||
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)
|
||||
|
||||
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) {
|
||||
// ShmSize is not supported on Windows
|
||||
testRequires(c, DaemonIsLinux)
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
Cmd: []string{"mount"},
|
||||
}
|
||||
|
@ -1480,7 +1480,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *testing.T) {
|
|||
assert.NilError(c, err)
|
||||
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)
|
||||
|
||||
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) {
|
||||
// ShmSize is not supported on Windows
|
||||
testRequires(c, DaemonIsLinux)
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
Cmd: []string{"mount"},
|
||||
}
|
||||
|
||||
hostConfig := containertypes.HostConfig{
|
||||
hostConfig := container.HostConfig{
|
||||
ShmSize: 1073741824,
|
||||
}
|
||||
|
||||
|
@ -1511,7 +1511,7 @@ func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *testing.T) {
|
|||
assert.NilError(c, err)
|
||||
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)
|
||||
|
||||
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) {
|
||||
// Swappiness is not supported on Windows
|
||||
testRequires(c, DaemonIsLinux)
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
}
|
||||
|
||||
|
@ -1537,7 +1537,7 @@ func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(
|
|||
assert.NilError(c, err)
|
||||
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)
|
||||
|
||||
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
|
||||
|
@ -1555,11 +1555,11 @@ func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *tes
|
|||
// OomScoreAdj is not supported on Windows
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
}
|
||||
|
||||
hostConfig := containertypes.HostConfig{
|
||||
hostConfig := container.HostConfig{
|
||||
OomScoreAdj: 1001,
|
||||
}
|
||||
|
||||
|
@ -1568,17 +1568,17 @@ func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *tes
|
|||
defer cli.Close()
|
||||
|
||||
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]"
|
||||
assert.ErrorContains(c, err, expected)
|
||||
|
||||
hostConfig = containertypes.HostConfig{
|
||||
hostConfig = container.HostConfig{
|
||||
OomScoreAdj: -1001,
|
||||
}
|
||||
|
||||
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]"
|
||||
assert.ErrorContains(c, err, expected)
|
||||
|
@ -1600,7 +1600,7 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) {
|
|||
|
||||
name := "testing-network-disabled"
|
||||
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
Cmd: []string{"top"},
|
||||
NetworkDisabled: true,
|
||||
|
@ -1610,7 +1610,7 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) {
|
|||
assert.NilError(c, err)
|
||||
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)
|
||||
|
||||
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) {
|
||||
type testCase struct {
|
||||
config containertypes.Config
|
||||
hostConfig containertypes.HostConfig
|
||||
config container.Config
|
||||
hostConfig container.HostConfig
|
||||
msg string
|
||||
}
|
||||
|
||||
|
@ -1656,11 +1656,11 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|||
|
||||
cases := []testCase{
|
||||
{
|
||||
config: containertypes.Config{
|
||||
config: container.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{{
|
||||
hostConfig: container.HostConfig{
|
||||
Mounts: []mount.Mount{{
|
||||
Type: "notreal",
|
||||
Target: destPath,
|
||||
},
|
||||
|
@ -1670,30 +1670,30 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|||
msg: "mount type unknown",
|
||||
},
|
||||
{
|
||||
config: containertypes.Config{
|
||||
config: container.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{{
|
||||
hostConfig: container.HostConfig{
|
||||
Mounts: []mount.Mount{{
|
||||
Type: "bind"}}},
|
||||
msg: "Target must not be empty",
|
||||
},
|
||||
{
|
||||
config: containertypes.Config{
|
||||
config: container.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{{
|
||||
hostConfig: container.HostConfig{
|
||||
Mounts: []mount.Mount{{
|
||||
Type: "bind",
|
||||
Target: destPath}}},
|
||||
msg: "Source must not be empty",
|
||||
},
|
||||
{
|
||||
config: containertypes.Config{
|
||||
config: container.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{{
|
||||
hostConfig: container.HostConfig{
|
||||
Mounts: []mount.Mount{{
|
||||
Type: "bind",
|
||||
Source: notExistPath,
|
||||
Target: destPath}}},
|
||||
|
@ -1702,36 +1702,36 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|||
// msg: "source path does not exist: " + notExistPath,
|
||||
},
|
||||
{
|
||||
config: containertypes.Config{
|
||||
config: container.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{{
|
||||
hostConfig: container.HostConfig{
|
||||
Mounts: []mount.Mount{{
|
||||
Type: "volume"}}},
|
||||
msg: "Target must not be empty",
|
||||
},
|
||||
{
|
||||
config: containertypes.Config{
|
||||
config: container.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{{
|
||||
hostConfig: container.HostConfig{
|
||||
Mounts: []mount.Mount{{
|
||||
Type: "volume",
|
||||
Source: "hello",
|
||||
Target: destPath}}},
|
||||
msg: "",
|
||||
},
|
||||
{
|
||||
config: containertypes.Config{
|
||||
config: container.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{{
|
||||
hostConfig: container.HostConfig{
|
||||
Mounts: []mount.Mount{{
|
||||
Type: "volume",
|
||||
Source: "hello2",
|
||||
Target: destPath,
|
||||
VolumeOptions: &mounttypes.VolumeOptions{
|
||||
DriverConfig: &mounttypes.Driver{
|
||||
VolumeOptions: &mount.VolumeOptions{
|
||||
DriverConfig: &mount.Driver{
|
||||
Name: "local"}}}}},
|
||||
msg: "",
|
||||
},
|
||||
|
@ -1743,26 +1743,26 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|||
defer os.RemoveAll(tmpDir)
|
||||
cases = append(cases, []testCase{
|
||||
{
|
||||
config: containertypes.Config{
|
||||
config: container.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{{
|
||||
hostConfig: container.HostConfig{
|
||||
Mounts: []mount.Mount{{
|
||||
Type: "bind",
|
||||
Source: tmpDir,
|
||||
Target: destPath}}},
|
||||
msg: "",
|
||||
},
|
||||
{
|
||||
config: containertypes.Config{
|
||||
config: container.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{{
|
||||
hostConfig: container.HostConfig{
|
||||
Mounts: []mount.Mount{{
|
||||
Type: "bind",
|
||||
Source: tmpDir,
|
||||
Target: destPath,
|
||||
VolumeOptions: &mounttypes.VolumeOptions{}}}},
|
||||
VolumeOptions: &mount.VolumeOptions{}}}},
|
||||
msg: "VolumeOptions must not be specified",
|
||||
},
|
||||
}...)
|
||||
|
@ -1771,17 +1771,17 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|||
if DaemonIsWindows() {
|
||||
cases = append(cases, []testCase{
|
||||
{
|
||||
config: containertypes.Config{
|
||||
config: container.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{
|
||||
hostConfig: container.HostConfig{
|
||||
Mounts: []mount.Mount{
|
||||
{
|
||||
Type: "volume",
|
||||
Source: "not-supported-on-windows",
|
||||
Target: destPath,
|
||||
VolumeOptions: &mounttypes.VolumeOptions{
|
||||
DriverConfig: &mounttypes.Driver{
|
||||
VolumeOptions: &mount.VolumeOptions{
|
||||
DriverConfig: &mount.Driver{
|
||||
Name: "local",
|
||||
Options: map[string]string{"type": "tmpfs"},
|
||||
},
|
||||
|
@ -1797,17 +1797,17 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|||
if DaemonIsLinux() {
|
||||
cases = append(cases, []testCase{
|
||||
{
|
||||
config: containertypes.Config{
|
||||
config: container.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{
|
||||
hostConfig: container.HostConfig{
|
||||
Mounts: []mount.Mount{
|
||||
{
|
||||
Type: "volume",
|
||||
Source: "missing-device-opt",
|
||||
Target: destPath,
|
||||
VolumeOptions: &mounttypes.VolumeOptions{
|
||||
DriverConfig: &mounttypes.Driver{
|
||||
VolumeOptions: &mount.VolumeOptions{
|
||||
DriverConfig: &mount.Driver{
|
||||
Name: "local",
|
||||
Options: map[string]string{"foobar": "foobaz"},
|
||||
},
|
||||
|
@ -1818,17 +1818,17 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|||
msg: `invalid option: "foobar"`,
|
||||
},
|
||||
{
|
||||
config: containertypes.Config{
|
||||
config: container.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{
|
||||
hostConfig: container.HostConfig{
|
||||
Mounts: []mount.Mount{
|
||||
{
|
||||
Type: "volume",
|
||||
Source: "missing-device-opt",
|
||||
Target: destPath,
|
||||
VolumeOptions: &mounttypes.VolumeOptions{
|
||||
DriverConfig: &mounttypes.Driver{
|
||||
VolumeOptions: &mount.VolumeOptions{
|
||||
DriverConfig: &mount.Driver{
|
||||
Name: "local",
|
||||
Options: map[string]string{"type": "tmpfs"},
|
||||
},
|
||||
|
@ -1839,17 +1839,17 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|||
msg: `missing required option: "device"`,
|
||||
},
|
||||
{
|
||||
config: containertypes.Config{
|
||||
config: container.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{
|
||||
hostConfig: container.HostConfig{
|
||||
Mounts: []mount.Mount{
|
||||
{
|
||||
Type: "volume",
|
||||
Source: "missing-type-opt",
|
||||
Target: destPath,
|
||||
VolumeOptions: &mounttypes.VolumeOptions{
|
||||
DriverConfig: &mounttypes.Driver{
|
||||
VolumeOptions: &mount.VolumeOptions{
|
||||
DriverConfig: &mount.Driver{
|
||||
Name: "local",
|
||||
Options: map[string]string{"device": "tmpfs"},
|
||||
},
|
||||
|
@ -1860,17 +1860,17 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|||
msg: `missing required option: "type"`,
|
||||
},
|
||||
{
|
||||
config: containertypes.Config{
|
||||
config: container.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{
|
||||
hostConfig: container.HostConfig{
|
||||
Mounts: []mount.Mount{
|
||||
{
|
||||
Type: "volume",
|
||||
Source: "hello4",
|
||||
Target: destPath,
|
||||
VolumeOptions: &mounttypes.VolumeOptions{
|
||||
DriverConfig: &mounttypes.Driver{
|
||||
VolumeOptions: &mount.VolumeOptions{
|
||||
DriverConfig: &mount.Driver{
|
||||
Name: "local",
|
||||
Options: map[string]string{"o": "size=1", "type": "tmpfs", "device": "tmpfs"},
|
||||
},
|
||||
|
@ -1881,35 +1881,35 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|||
msg: "",
|
||||
},
|
||||
{
|
||||
config: containertypes.Config{
|
||||
config: container.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{{
|
||||
hostConfig: container.HostConfig{
|
||||
Mounts: []mount.Mount{{
|
||||
Type: "tmpfs",
|
||||
Target: destPath}}},
|
||||
msg: "",
|
||||
},
|
||||
{
|
||||
config: containertypes.Config{
|
||||
config: container.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{{
|
||||
hostConfig: container.HostConfig{
|
||||
Mounts: []mount.Mount{{
|
||||
Type: "tmpfs",
|
||||
Target: destPath,
|
||||
TmpfsOptions: &mounttypes.TmpfsOptions{
|
||||
TmpfsOptions: &mount.TmpfsOptions{
|
||||
SizeBytes: 4096 * 1024,
|
||||
Mode: 0700,
|
||||
}}}},
|
||||
msg: "",
|
||||
},
|
||||
{
|
||||
config: containertypes.Config{
|
||||
config: container.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{{
|
||||
hostConfig: container.HostConfig{
|
||||
Mounts: []mount.Mount{{
|
||||
Type: "tmpfs",
|
||||
Source: "/shouldnotbespecified",
|
||||
Target: destPath}}},
|
||||
|
@ -1926,7 +1926,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|||
for i, x := range cases {
|
||||
x := x
|
||||
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 {
|
||||
assert.ErrorContains(c, err, x.msg, "%v", cases[i].config)
|
||||
} else {
|
||||
|
@ -1946,12 +1946,12 @@ func (s *DockerSuite) TestContainerAPICreateMountsBindRead(c *testing.T) {
|
|||
defer os.RemoveAll(tmpDir)
|
||||
err = os.WriteFile(filepath.Join(tmpDir, "bar"), []byte("hello"), 0666)
|
||||
assert.NilError(c, err)
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
Cmd: []string{"/bin/sh", "-c", "cat /foo/bar"},
|
||||
}
|
||||
hostConfig := containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{
|
||||
hostConfig := container.HostConfig{
|
||||
Mounts: []mount.Mount{
|
||||
{Type: "bind", Source: tmpDir, Target: destPath},
|
||||
},
|
||||
}
|
||||
|
@ -1959,7 +1959,7 @@ func (s *DockerSuite) TestContainerAPICreateMountsBindRead(c *testing.T) {
|
|||
assert.NilError(c, err)
|
||||
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)
|
||||
|
||||
out, _ := dockerCmd(c, "start", "-a", "test")
|
||||
|
@ -1986,7 +1986,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
|
|||
}
|
||||
|
||||
type testCase struct {
|
||||
spec mounttypes.Mount
|
||||
spec mount.Mount
|
||||
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
|
||||
// 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},
|
||||
},
|
||||
{
|
||||
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},
|
||||
},
|
||||
{
|
||||
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},
|
||||
},
|
||||
{
|
||||
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},
|
||||
},
|
||||
{
|
||||
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},
|
||||
},
|
||||
}
|
||||
|
@ -2032,7 +2032,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
|
|||
defer os.RemoveAll(tmpDir1)
|
||||
cases = append(cases, []testCase{
|
||||
{
|
||||
spec: mounttypes.Mount{
|
||||
spec: mount.Mount{
|
||||
Type: "bind",
|
||||
Source: tmpDir1,
|
||||
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},
|
||||
},
|
||||
}...)
|
||||
|
@ -2060,15 +2060,15 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
|
|||
|
||||
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},
|
||||
},
|
||||
{
|
||||
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},
|
||||
},
|
||||
{
|
||||
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"},
|
||||
},
|
||||
}...)
|
||||
|
@ -2078,19 +2078,19 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
|
|||
if testEnv.OSType != "windows" { // Windows does not support volume populate
|
||||
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},
|
||||
},
|
||||
{
|
||||
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},
|
||||
},
|
||||
{
|
||||
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},
|
||||
},
|
||||
{
|
||||
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},
|
||||
},
|
||||
}...)
|
||||
|
@ -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) {
|
||||
container, err := apiclient.ContainerCreate(
|
||||
ctx,
|
||||
&containertypes.Config{Image: testImg},
|
||||
&containertypes.HostConfig{Mounts: []mounttypes.Mount{x.spec}},
|
||||
&networktypes.NetworkingConfig{},
|
||||
&container.Config{Image: testImg},
|
||||
&container.HostConfig{Mounts: []mount.Mount{x.spec}},
|
||||
&network.NetworkingConfig{},
|
||||
nil,
|
||||
"")
|
||||
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) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
type testCase struct {
|
||||
cfg mounttypes.Mount
|
||||
cfg mount.Mount
|
||||
expectedOptions []string
|
||||
}
|
||||
target := "/foo"
|
||||
cases := []testCase{
|
||||
{
|
||||
cfg: mounttypes.Mount{
|
||||
cfg: mount.Mount{
|
||||
Type: "tmpfs",
|
||||
Target: target},
|
||||
expectedOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime"},
|
||||
},
|
||||
{
|
||||
cfg: mounttypes.Mount{
|
||||
cfg: mount.Mount{
|
||||
Type: "tmpfs",
|
||||
Target: target,
|
||||
TmpfsOptions: &mounttypes.TmpfsOptions{
|
||||
TmpfsOptions: &mount.TmpfsOptions{
|
||||
SizeBytes: 4096 * 1024, Mode: 0700}},
|
||||
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)
|
||||
defer cli.Close()
|
||||
|
||||
config := containertypes.Config{
|
||||
config := container.Config{
|
||||
Image: "busybox",
|
||||
Cmd: []string{"/bin/sh", "-c", fmt.Sprintf("mount | grep 'tmpfs on %s'", target)},
|
||||
}
|
||||
for i, x := range cases {
|
||||
cName := fmt.Sprintf("test-tmpfs-%d", i)
|
||||
hostConfig := containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{x.cfg},
|
||||
hostConfig := container.HostConfig{
|
||||
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)
|
||||
out, _ := dockerCmd(c, "start", "-a", cName)
|
||||
for _, option := range x.expectedOptions {
|
||||
|
|
Loading…
Add table
Reference in a new issue