summaryrefslogtreecommitdiff
path: root/libpod/options.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/options.go')
-rw-r--r--libpod/options.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/libpod/options.go b/libpod/options.go
index 1fe472ccc..3020ef51a 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -6,6 +6,7 @@ import (
"github.com/containers/storage"
"github.com/containers/storage/pkg/idtools"
+ "github.com/cri-o/ocicni/pkg/ocicni"
"github.com/pkg/errors"
)
@@ -402,6 +403,22 @@ func WithStopSignal(signal uint) CtrCreateOption {
}
}
+// WithNetNS indicates that the container should be given a new network
+// namespace with a minimal configuration
+// An optional array of port mappings can be provided
+func WithNetNS(portMappings []ocicni.PortMapping) CtrCreateOption {
+ return func(ctr *Container) error {
+ if ctr.valid {
+ return ErrCtrFinalized
+ }
+
+ ctr.config.CreateNetNS = true
+ copy(ctr.config.PortMappings, portMappings)
+
+ return nil
+ }
+}
+
// Pod Creation Options
// WithPodName sets the name of the pod