|
@@ -3,9 +3,9 @@ package container
|
|
import (
|
|
import (
|
|
"strings"
|
|
"strings"
|
|
|
|
|
|
- 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/strslice"
|
|
"github.com/docker/docker/api/types/strslice"
|
|
"github.com/docker/go-connections/nat"
|
|
"github.com/docker/go-connections/nat"
|
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
|
@@ -42,7 +42,7 @@ func WithCmd(cmds ...string) func(*TestContainerConfig) {
|
|
// WithNetworkMode sets the network mode of the container
|
|
// WithNetworkMode sets the network mode of the container
|
|
func WithNetworkMode(mode string) func(*TestContainerConfig) {
|
|
func WithNetworkMode(mode string) func(*TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
- c.HostConfig.NetworkMode = containertypes.NetworkMode(mode)
|
|
|
|
|
|
+ c.HostConfig.NetworkMode = container.NetworkMode(mode)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -71,7 +71,7 @@ func WithWorkingDir(dir string) func(*TestContainerConfig) {
|
|
}
|
|
}
|
|
|
|
|
|
// WithMount adds an mount
|
|
// WithMount adds an mount
|
|
-func WithMount(m mounttypes.Mount) func(*TestContainerConfig) {
|
|
|
|
|
|
+func WithMount(m mount.Mount) func(*TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
c.HostConfig.Mounts = append(c.HostConfig.Mounts, m)
|
|
c.HostConfig.Mounts = append(c.HostConfig.Mounts, m)
|
|
}
|
|
}
|
|
@@ -115,34 +115,34 @@ func WithTmpfs(targetAndOpts string) func(config *TestContainerConfig) {
|
|
}
|
|
}
|
|
|
|
|
|
// WithIPv4 sets the specified ip for the specified network of the container
|
|
// WithIPv4 sets the specified ip for the specified network of the container
|
|
-func WithIPv4(network, ip string) func(*TestContainerConfig) {
|
|
|
|
|
|
+func WithIPv4(networkName, ip string) func(*TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
if c.NetworkingConfig.EndpointsConfig == nil {
|
|
if c.NetworkingConfig.EndpointsConfig == nil {
|
|
- c.NetworkingConfig.EndpointsConfig = map[string]*networktypes.EndpointSettings{}
|
|
|
|
|
|
+ c.NetworkingConfig.EndpointsConfig = map[string]*network.EndpointSettings{}
|
|
}
|
|
}
|
|
- if v, ok := c.NetworkingConfig.EndpointsConfig[network]; !ok || v == nil {
|
|
|
|
- c.NetworkingConfig.EndpointsConfig[network] = &networktypes.EndpointSettings{}
|
|
|
|
|
|
+ if v, ok := c.NetworkingConfig.EndpointsConfig[networkName]; !ok || v == nil {
|
|
|
|
+ c.NetworkingConfig.EndpointsConfig[networkName] = &network.EndpointSettings{}
|
|
}
|
|
}
|
|
- if c.NetworkingConfig.EndpointsConfig[network].IPAMConfig == nil {
|
|
|
|
- c.NetworkingConfig.EndpointsConfig[network].IPAMConfig = &networktypes.EndpointIPAMConfig{}
|
|
|
|
|
|
+ if c.NetworkingConfig.EndpointsConfig[networkName].IPAMConfig == nil {
|
|
|
|
+ c.NetworkingConfig.EndpointsConfig[networkName].IPAMConfig = &network.EndpointIPAMConfig{}
|
|
}
|
|
}
|
|
- c.NetworkingConfig.EndpointsConfig[network].IPAMConfig.IPv4Address = ip
|
|
|
|
|
|
+ c.NetworkingConfig.EndpointsConfig[networkName].IPAMConfig.IPv4Address = ip
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// WithIPv6 sets the specified ip6 for the specified network of the container
|
|
// WithIPv6 sets the specified ip6 for the specified network of the container
|
|
-func WithIPv6(network, ip string) func(*TestContainerConfig) {
|
|
|
|
|
|
+func WithIPv6(networkName, ip string) func(*TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
if c.NetworkingConfig.EndpointsConfig == nil {
|
|
if c.NetworkingConfig.EndpointsConfig == nil {
|
|
- c.NetworkingConfig.EndpointsConfig = map[string]*networktypes.EndpointSettings{}
|
|
|
|
|
|
+ c.NetworkingConfig.EndpointsConfig = map[string]*network.EndpointSettings{}
|
|
}
|
|
}
|
|
- if v, ok := c.NetworkingConfig.EndpointsConfig[network]; !ok || v == nil {
|
|
|
|
- c.NetworkingConfig.EndpointsConfig[network] = &networktypes.EndpointSettings{}
|
|
|
|
|
|
+ if v, ok := c.NetworkingConfig.EndpointsConfig[networkName]; !ok || v == nil {
|
|
|
|
+ c.NetworkingConfig.EndpointsConfig[networkName] = &network.EndpointSettings{}
|
|
}
|
|
}
|
|
- if c.NetworkingConfig.EndpointsConfig[network].IPAMConfig == nil {
|
|
|
|
- c.NetworkingConfig.EndpointsConfig[network].IPAMConfig = &networktypes.EndpointIPAMConfig{}
|
|
|
|
|
|
+ if c.NetworkingConfig.EndpointsConfig[networkName].IPAMConfig == nil {
|
|
|
|
+ c.NetworkingConfig.EndpointsConfig[networkName].IPAMConfig = &network.EndpointIPAMConfig{}
|
|
}
|
|
}
|
|
- c.NetworkingConfig.EndpointsConfig[network].IPAMConfig.IPv6Address = ip
|
|
|
|
|
|
+ c.NetworkingConfig.EndpointsConfig[networkName].IPAMConfig.IPv6Address = ip
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -162,7 +162,7 @@ func WithAutoRemove(c *TestContainerConfig) {
|
|
func WithPidsLimit(limit *int64) func(*TestContainerConfig) {
|
|
func WithPidsLimit(limit *int64) func(*TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
if c.HostConfig == nil {
|
|
if c.HostConfig == nil {
|
|
- c.HostConfig = &containertypes.HostConfig{}
|
|
|
|
|
|
+ c.HostConfig = &container.HostConfig{}
|
|
}
|
|
}
|
|
c.HostConfig.PidsLimit = limit
|
|
c.HostConfig.PidsLimit = limit
|
|
}
|
|
}
|
|
@@ -186,7 +186,7 @@ func WithUser(user string) func(c *TestContainerConfig) {
|
|
func WithPrivileged(privileged bool) func(*TestContainerConfig) {
|
|
func WithPrivileged(privileged bool) func(*TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
if c.HostConfig == nil {
|
|
if c.HostConfig == nil {
|
|
- c.HostConfig = &containertypes.HostConfig{}
|
|
|
|
|
|
+ c.HostConfig = &container.HostConfig{}
|
|
}
|
|
}
|
|
c.HostConfig.Privileged = privileged
|
|
c.HostConfig.Privileged = privileged
|
|
}
|
|
}
|
|
@@ -196,9 +196,9 @@ func WithPrivileged(privileged bool) func(*TestContainerConfig) {
|
|
func WithCgroupnsMode(mode string) func(*TestContainerConfig) {
|
|
func WithCgroupnsMode(mode string) func(*TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
if c.HostConfig == nil {
|
|
if c.HostConfig == nil {
|
|
- c.HostConfig = &containertypes.HostConfig{}
|
|
|
|
|
|
+ c.HostConfig = &container.HostConfig{}
|
|
}
|
|
}
|
|
- c.HostConfig.CgroupnsMode = containertypes.CgroupnsMode(mode)
|
|
|
|
|
|
+ c.HostConfig.CgroupnsMode = container.CgroupnsMode(mode)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -220,12 +220,12 @@ func WithPlatform(p *ocispec.Platform) func(*TestContainerConfig) {
|
|
// WithWindowsDevice specifies a Windows Device, ala `--device` on the CLI
|
|
// WithWindowsDevice specifies a Windows Device, ala `--device` on the CLI
|
|
func WithWindowsDevice(device string) func(*TestContainerConfig) {
|
|
func WithWindowsDevice(device string) func(*TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
- c.HostConfig.Devices = append(c.HostConfig.Devices, containertypes.DeviceMapping{PathOnHost: device})
|
|
|
|
|
|
+ c.HostConfig.Devices = append(c.HostConfig.Devices, container.DeviceMapping{PathOnHost: device})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// WithIsolation specifies the isolation technology to apply to the container
|
|
// WithIsolation specifies the isolation technology to apply to the container
|
|
-func WithIsolation(isolation containertypes.Isolation) func(*TestContainerConfig) {
|
|
|
|
|
|
+func WithIsolation(isolation container.Isolation) func(*TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
c.HostConfig.Isolation = isolation
|
|
c.HostConfig.Isolation = isolation
|
|
}
|
|
}
|
|
@@ -248,7 +248,7 @@ func WithRuntime(name string) func(*TestContainerConfig) {
|
|
// WithCDIDevices sets the CDI devices to use to start the container
|
|
// WithCDIDevices sets the CDI devices to use to start the container
|
|
func WithCDIDevices(cdiDeviceNames ...string) func(*TestContainerConfig) {
|
|
func WithCDIDevices(cdiDeviceNames ...string) func(*TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
return func(c *TestContainerConfig) {
|
|
- request := containertypes.DeviceRequest{
|
|
|
|
|
|
+ request := container.DeviceRequest{
|
|
Driver: "cdi",
|
|
Driver: "cdi",
|
|
DeviceIDs: cdiDeviceNames,
|
|
DeviceIDs: cdiDeviceNames,
|
|
}
|
|
}
|