From f7321681d04d65da3b307d1e5e4ba12c42b5c456 Mon Sep 17 00:00:00 2001 From: cdoern Date: Wed, 7 Jul 2021 17:00:30 -0400 Subject: podman pod create --pid flag added support for --pid flag. User can specify ns:file, pod, private, or host. container returns an error since you cannot point the ns of the pods infra container to a container outside of the pod. Signed-off-by: cdoern --- libpod/options.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'libpod/options.go') diff --git a/libpod/options.go b/libpod/options.go index b12153512..bc563d60c 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -16,6 +16,7 @@ import ( "github.com/containers/podman/v3/libpod/events" "github.com/containers/podman/v3/pkg/namespaces" "github.com/containers/podman/v3/pkg/rootless" + "github.com/containers/podman/v3/pkg/specgen" "github.com/containers/podman/v3/pkg/util" "github.com/containers/storage" "github.com/containers/storage/pkg/idtools" @@ -2397,3 +2398,22 @@ func WithPodCPUSetCPUs(inp string) PodCreateOption { return nil } } + +func WithPodPidNS(inp specgen.Namespace) PodCreateOption { + return func(p *Pod) error { + if p.valid { + return define.ErrPodFinalized + } + if p.config.UsePodPID { + switch inp.NSMode { + case "container": + return errors.Wrap(define.ErrInvalidArg, "Cannot take container in a different NS as an argument") + case "host": + p.config.UsePodPID = false + } + p.config.InfraContainer.PidNS = inp + } + + return nil + } +} -- cgit v1.2.3-54-g00ecf