mirror of
https://github.com/containers/podman.git
synced 2025-06-06 23:08:04 +08:00
Merge pull request #5627 from baude/apiv2createnet
apiv2 add default network in specgen
This commit is contained in:
@ -3,6 +3,8 @@ package specgen
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/libpod/pkg/rootless"
|
||||||
|
|
||||||
"github.com/containers/libpod/libpod"
|
"github.com/containers/libpod/libpod"
|
||||||
"github.com/containers/libpod/pkg/util"
|
"github.com/containers/libpod/pkg/util"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -138,9 +140,6 @@ func (s *SpecGenerator) validate(rt *libpod.Runtime) error {
|
|||||||
if err := s.IpcNS.validate(); err != nil {
|
if err := s.IpcNS.validate(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := validateNetNS(&s.NetNS); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := s.PidNS.validate(); err != nil {
|
if err := s.PidNS.validate(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -155,5 +154,16 @@ func (s *SpecGenerator) validate(rt *libpod.Runtime) error {
|
|||||||
if len(s.WorkDir) < 1 {
|
if len(s.WorkDir) < 1 {
|
||||||
s.WorkDir = "/"
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user