diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-08-24 18:35:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-24 18:35:59 -0400 |
commit | 024f47068a894907ee47b1b90c86090a00586940 (patch) | |
tree | 4528b3566c3162ca2892b8c3d752d3957161e3d5 /pkg/specgen/container_validate.go | |
parent | c78c6b44ce63430218e141415a10b2010d42f883 (diff) | |
parent | 13d5b2d661478005a0b7eec5563d13580b6cd3f8 (diff) | |
download | podman-024f47068a894907ee47b1b90c86090a00586940.tar.gz podman-024f47068a894907ee47b1b90c86090a00586940.tar.bz2 podman-024f47068a894907ee47b1b90c86090a00586940.zip |
Merge pull request #7402 from mheon/last_pr_before_205_really_this_time
Final v2.0.5 backports
Diffstat (limited to 'pkg/specgen/container_validate.go')
-rw-r--r-- | pkg/specgen/container_validate.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/pkg/specgen/container_validate.go b/pkg/specgen/container_validate.go index 4dd2ab0b3..c4449ba3a 100644 --- a/pkg/specgen/container_validate.go +++ b/pkg/specgen/container_validate.go @@ -3,6 +3,7 @@ package specgen import ( "strings" + "github.com/containers/libpod/v2/libpod/define" "github.com/containers/libpod/v2/pkg/rootless" "github.com/containers/libpod/v2/pkg/util" "github.com/pkg/errors" @@ -34,6 +35,23 @@ func (s *SpecGenerator) Validate() error { } } + // Containers being added to a pod cannot have certain network attributes + // associated with them because those should be on the infra container. + if len(s.Pod) > 0 && s.NetNS.NSMode == FromPod { + if s.StaticIP != nil || s.StaticIPv6 != nil { + return errors.Wrap(define.ErrNetworkOnPodContainer, "static ip addresses must be defined when the pod is created") + } + if s.StaticMAC != nil { + return errors.Wrap(define.ErrNetworkOnPodContainer, "MAC addresses must be defined when the pod is created") + } + if len(s.CNINetworks) > 0 { + return errors.Wrap(define.ErrNetworkOnPodContainer, "networks must be defined when the pod is created") + } + if len(s.PortMappings) > 0 || s.PublishExposedPorts { + return errors.Wrap(define.ErrNetworkOnPodContainer, "published or exposed ports must be defined when the pod is created") + } + } + // // ContainerBasicConfig // |