diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-03-26 18:59:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-26 18:59:47 +0100 |
commit | 14ece7ecaf6e2b7fe65d64ed872fbfe2d740f48b (patch) | |
tree | 70750b64c0adccc87ad35fc4b06359b8d032fac1 /pkg | |
parent | e2cab552de969a5e2c276f8db97d6491f6c09b3e (diff) | |
parent | cac8bcdd7ec17dd78c12b0bf45af20e2644890b1 (diff) | |
download | podman-14ece7ecaf6e2b7fe65d64ed872fbfe2d740f48b.tar.gz podman-14ece7ecaf6e2b7fe65d64ed872fbfe2d740f48b.tar.bz2 podman-14ece7ecaf6e2b7fe65d64ed872fbfe2d740f48b.zip |
Merge pull request #5627 from baude/apiv2createnet
apiv2 add default network in specgen
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/specgen/validate.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/pkg/specgen/validate.go b/pkg/specgen/validate.go index dd5ca3a55..5f567f725 100644 --- a/pkg/specgen/validate.go +++ b/pkg/specgen/validate.go @@ -3,6 +3,8 @@ package specgen import ( "strings" + "github.com/containers/libpod/pkg/rootless" + "github.com/containers/libpod/libpod" "github.com/containers/libpod/pkg/util" "github.com/pkg/errors" @@ -138,9 +140,6 @@ func (s *SpecGenerator) validate(rt *libpod.Runtime) error { if err := s.IpcNS.validate(); err != nil { return err } - if err := validateNetNS(&s.NetNS); err != nil { - return err - } if err := s.PidNS.validate(); err != nil { return err } @@ -155,5 +154,16 @@ func (s *SpecGenerator) validate(rt *libpod.Runtime) error { if len(s.WorkDir) < 1 { s.WorkDir = "/" } + + // Set defaults if network info is not provided + if s.NetNS.NSMode == "" { + s.NetNS.NSMode = Bridge + if rootless.IsRootless() { + s.NetNS.NSMode = Slirp + } + } + if err := validateNetNS(&s.NetNS); err != nil { + return err + } return nil } |