diff options
author | Matthew Heon <matthew.heon@pm.me> | 2020-05-04 13:14:33 -0400 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2020-05-04 20:57:27 -0400 |
commit | 7ac3d906b5c080803f7898d3307af87bb57ad436 (patch) | |
tree | c8f31a0b79b609484bb9ef0f3eb78fd799510eff /pkg/specgen/podspecgen.go | |
parent | 01aad516e012fe46179e053addd7a8a84788228b (diff) | |
download | podman-7ac3d906b5c080803f7898d3307af87bb57ad436.tar.gz podman-7ac3d906b5c080803f7898d3307af87bb57ad436.tar.bz2 podman-7ac3d906b5c080803f7898d3307af87bb57ad436.zip |
Rework port parsing to support --expose and -P
As part of this, make a major change to the type we use to
represent port mappings in SpecGen (from using existing OCICNI
structs to using our own custom one). This struct has the
advantage of supporting ranges, massively reducing traffic over
the wire for Podman commands using them (for example, the
`podman run -p 5000-6000` command will now send only one struct
instead of 1000). This struct also allows us to easily validate
which ports are in use, and which are not, which is necessary for
--expose.
Once we have parsed the ports from the new struct, we can produce
an accurate map including all currently requested ports, and use
that to determine what ports need to be exposed (some requested
exposed ports may already be included in a mapping from --publish
and will be ignored) and what open ports on the host we can map
them to.
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'pkg/specgen/podspecgen.go')
-rw-r--r-- | pkg/specgen/podspecgen.go | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/pkg/specgen/podspecgen.go b/pkg/specgen/podspecgen.go index 3f830014d..682f3f215 100644 --- a/pkg/specgen/podspecgen.go +++ b/pkg/specgen/podspecgen.go @@ -2,8 +2,6 @@ package specgen import ( "net" - - "github.com/cri-o/ocicni/pkg/ocicni" ) // PodBasicConfig contains basic configuration options for pods. @@ -79,7 +77,7 @@ type PodNetworkConfig struct { // container, this will forward the ports to the entire pod. // Only available if NetNS is set to Bridge or Slirp. // Optional. - PortMappings []ocicni.PortMapping `json:"portmappings,omitempty"` + PortMappings []PortMapping `json:"portmappings,omitempty"` // CNINetworks is a list of CNI networks that the infra container will // join. As, by default, containers share their network with the infra // container, these networks will effectively be joined by the |