summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2020-03-26 11:56:56 -0500
committerBrent Baude <bbaude@redhat.com>2020-03-26 11:58:22 -0500
commitcac8bcdd7ec17dd78c12b0bf45af20e2644890b1 (patch)
tree2f178d6a549846f6a79eefcdbf879ed1b1e1d9e2 /pkg
parent8cccac54979b804d1086ff42654de07dba802a2e (diff)
downloadpodman-cac8bcdd7ec17dd78c12b0bf45af20e2644890b1.tar.gz
podman-cac8bcdd7ec17dd78c12b0bf45af20e2644890b1.tar.bz2
podman-cac8bcdd7ec17dd78c12b0bf45af20e2644890b1.zip
apiv2 add default network in specgen
when a network is not provided, we should set a default mode based on rootless or rootfull. Fixes: #5366 Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/specgen/validate.go16
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
}