From 494677f93f04ab3ad4c295c0e92ac05bfe0a546a Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 30 Jul 2025 14:49:19 +0200 Subject: [PATCH] api/types/container: add aliases for go-connections/nat types This allows us to update code to not be attached to go-connections directly (in future we may be able to move the types to be concrete types). Signed-off-by: Sebastiaan van Stijn --- api/types/container/config.go | 3 +-- api/types/container/hostconfig.go | 3 +-- api/types/container/nat_aliases.go | 24 +++++++++++++++++++ api/types/container/network_settings.go | 9 ++++--- .../moby/moby/api/types/container/config.go | 3 +-- .../moby/api/types/container/hostconfig.go | 3 +-- .../moby/api/types/container/nat_aliases.go | 24 +++++++++++++++++++ .../api/types/container/network_settings.go | 9 ++++--- 8 files changed, 60 insertions(+), 18 deletions(-) create mode 100644 api/types/container/nat_aliases.go create mode 100644 vendor/github.com/moby/moby/api/types/container/nat_aliases.go diff --git a/api/types/container/config.go b/api/types/container/config.go index 0eba9f6841..6ea9e079dd 100644 --- a/api/types/container/config.go +++ b/api/types/container/config.go @@ -3,7 +3,6 @@ package container import ( "time" - "github.com/docker/go-connections/nat" dockerspec "github.com/moby/docker-image-spec/specs-go/v1" "github.com/moby/moby/api/types/strslice" ) @@ -48,7 +47,7 @@ type Config struct { AttachStdin bool // Attach the standard input, makes possible user interaction AttachStdout bool // Attach the standard output AttachStderr bool // Attach the standard error - ExposedPorts nat.PortSet `json:",omitempty"` // List of exposed ports + ExposedPorts PortSet `json:",omitempty"` // List of exposed ports Tty bool // Attach standard streams to a tty, including stdin if it is not closed. OpenStdin bool // Open stdin StdinOnce bool // If true, close stdin after the 1 attached client disconnects. diff --git a/api/types/container/hostconfig.go b/api/types/container/hostconfig.go index cf27f63fce..65d4300532 100644 --- a/api/types/container/hostconfig.go +++ b/api/types/container/hostconfig.go @@ -5,7 +5,6 @@ import ( "fmt" "strings" - "github.com/docker/go-connections/nat" "github.com/docker/go-units" "github.com/moby/moby/api/types/blkiodev" "github.com/moby/moby/api/types/mount" @@ -427,7 +426,7 @@ type HostConfig struct { ContainerIDFile string // File (path) where the containerId is written LogConfig LogConfig // Configuration of the logs for this container NetworkMode NetworkMode // Network mode to use for the container - PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host + PortBindings PortMap // Port mapping between the exposed port (container) and the host RestartPolicy RestartPolicy // Restart policy to be used for the container AutoRemove bool // Automatically remove container when it exits VolumeDriver string // Name of the volume driver used to mount volumes diff --git a/api/types/container/nat_aliases.go b/api/types/container/nat_aliases.go new file mode 100644 index 0000000000..470f15655c --- /dev/null +++ b/api/types/container/nat_aliases.go @@ -0,0 +1,24 @@ +package container + +import "github.com/docker/go-connections/nat" + +// PortRangeProto is a string containing port number and protocol in the format "80/tcp", +// or a port range and protocol in the format "80-83/tcp". +// +// It is currently an alias for [nat.Port] but may become a concrete type in a future release. +type PortRangeProto = nat.Port + +// PortSet is a collection of structs indexed by [HostPort]. +// +// It is currently an alias for [nat.PortSet] but may become a concrete type in a future release. +type PortSet = nat.PortSet + +// PortBinding represents a binding between a Host IP address and a [HostPort]. +// +// It is currently an alias for [nat.PortBinding] but may become a concrete type in a future release. +type PortBinding = nat.PortBinding + +// PortMap is a collection of [PortBinding] indexed by [HostPort]. +// +// It is currently an alias for [nat.PortMap] but may become a concrete type in a future release. +type PortMap = nat.PortMap diff --git a/api/types/container/network_settings.go b/api/types/container/network_settings.go index d7dee99e72..40d5cbd1de 100644 --- a/api/types/container/network_settings.go +++ b/api/types/container/network_settings.go @@ -1,7 +1,6 @@ package container import ( - "github.com/docker/go-connections/nat" "github.com/moby/moby/api/types/network" ) @@ -14,10 +13,10 @@ type NetworkSettings struct { // NetworkSettingsBase holds networking state for a container when inspecting it. type NetworkSettingsBase struct { - Bridge string // Bridge contains the name of the default bridge interface iff it was set through the daemon --bridge flag. - SandboxID string // SandboxID uniquely represents a container's network stack - SandboxKey string // SandboxKey identifies the sandbox - Ports nat.PortMap // Ports is a collection of PortBinding indexed by Port + Bridge string // Bridge contains the name of the default bridge interface iff it was set through the daemon --bridge flag. + SandboxID string // SandboxID uniquely represents a container's network stack + SandboxKey string // SandboxKey identifies the sandbox + Ports PortMap // Ports is a collection of PortBinding indexed by Port // HairpinMode specifies if hairpin NAT should be enabled on the virtual interface // diff --git a/vendor/github.com/moby/moby/api/types/container/config.go b/vendor/github.com/moby/moby/api/types/container/config.go index 0eba9f6841..6ea9e079dd 100644 --- a/vendor/github.com/moby/moby/api/types/container/config.go +++ b/vendor/github.com/moby/moby/api/types/container/config.go @@ -3,7 +3,6 @@ package container import ( "time" - "github.com/docker/go-connections/nat" dockerspec "github.com/moby/docker-image-spec/specs-go/v1" "github.com/moby/moby/api/types/strslice" ) @@ -48,7 +47,7 @@ type Config struct { AttachStdin bool // Attach the standard input, makes possible user interaction AttachStdout bool // Attach the standard output AttachStderr bool // Attach the standard error - ExposedPorts nat.PortSet `json:",omitempty"` // List of exposed ports + ExposedPorts PortSet `json:",omitempty"` // List of exposed ports Tty bool // Attach standard streams to a tty, including stdin if it is not closed. OpenStdin bool // Open stdin StdinOnce bool // If true, close stdin after the 1 attached client disconnects. diff --git a/vendor/github.com/moby/moby/api/types/container/hostconfig.go b/vendor/github.com/moby/moby/api/types/container/hostconfig.go index cf27f63fce..65d4300532 100644 --- a/vendor/github.com/moby/moby/api/types/container/hostconfig.go +++ b/vendor/github.com/moby/moby/api/types/container/hostconfig.go @@ -5,7 +5,6 @@ import ( "fmt" "strings" - "github.com/docker/go-connections/nat" "github.com/docker/go-units" "github.com/moby/moby/api/types/blkiodev" "github.com/moby/moby/api/types/mount" @@ -427,7 +426,7 @@ type HostConfig struct { ContainerIDFile string // File (path) where the containerId is written LogConfig LogConfig // Configuration of the logs for this container NetworkMode NetworkMode // Network mode to use for the container - PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host + PortBindings PortMap // Port mapping between the exposed port (container) and the host RestartPolicy RestartPolicy // Restart policy to be used for the container AutoRemove bool // Automatically remove container when it exits VolumeDriver string // Name of the volume driver used to mount volumes diff --git a/vendor/github.com/moby/moby/api/types/container/nat_aliases.go b/vendor/github.com/moby/moby/api/types/container/nat_aliases.go new file mode 100644 index 0000000000..470f15655c --- /dev/null +++ b/vendor/github.com/moby/moby/api/types/container/nat_aliases.go @@ -0,0 +1,24 @@ +package container + +import "github.com/docker/go-connections/nat" + +// PortRangeProto is a string containing port number and protocol in the format "80/tcp", +// or a port range and protocol in the format "80-83/tcp". +// +// It is currently an alias for [nat.Port] but may become a concrete type in a future release. +type PortRangeProto = nat.Port + +// PortSet is a collection of structs indexed by [HostPort]. +// +// It is currently an alias for [nat.PortSet] but may become a concrete type in a future release. +type PortSet = nat.PortSet + +// PortBinding represents a binding between a Host IP address and a [HostPort]. +// +// It is currently an alias for [nat.PortBinding] but may become a concrete type in a future release. +type PortBinding = nat.PortBinding + +// PortMap is a collection of [PortBinding] indexed by [HostPort]. +// +// It is currently an alias for [nat.PortMap] but may become a concrete type in a future release. +type PortMap = nat.PortMap diff --git a/vendor/github.com/moby/moby/api/types/container/network_settings.go b/vendor/github.com/moby/moby/api/types/container/network_settings.go index d7dee99e72..40d5cbd1de 100644 --- a/vendor/github.com/moby/moby/api/types/container/network_settings.go +++ b/vendor/github.com/moby/moby/api/types/container/network_settings.go @@ -1,7 +1,6 @@ package container import ( - "github.com/docker/go-connections/nat" "github.com/moby/moby/api/types/network" ) @@ -14,10 +13,10 @@ type NetworkSettings struct { // NetworkSettingsBase holds networking state for a container when inspecting it. type NetworkSettingsBase struct { - Bridge string // Bridge contains the name of the default bridge interface iff it was set through the daemon --bridge flag. - SandboxID string // SandboxID uniquely represents a container's network stack - SandboxKey string // SandboxKey identifies the sandbox - Ports nat.PortMap // Ports is a collection of PortBinding indexed by Port + Bridge string // Bridge contains the name of the default bridge interface iff it was set through the daemon --bridge flag. + SandboxID string // SandboxID uniquely represents a container's network stack + SandboxKey string // SandboxKey identifies the sandbox + Ports PortMap // Ports is a collection of PortBinding indexed by Port // HairpinMode specifies if hairpin NAT should be enabled on the virtual interface //