From 697b46430a8a7c2c7231078911dcec51f0c6fab5 Mon Sep 17 00:00:00 2001 From: haircommander Date: Thu, 16 Aug 2018 17:12:16 -0400 Subject: Support pause containers in varlink Signed-off-by: haircommander Closes: #1187 Approved by: mheon --- cmd/podman/shared/pod.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'cmd/podman/shared') diff --git a/cmd/podman/shared/pod.go b/cmd/podman/shared/pod.go index c660bcf9e..99f9f6031 100644 --- a/cmd/podman/shared/pod.go +++ b/cmd/podman/shared/pod.go @@ -2,6 +2,7 @@ package shared import ( "github.com/containers/libpod/libpod" + "github.com/pkg/errors" ) const ( @@ -60,3 +61,35 @@ func GetPodStatus(pod *libpod.Pod) (string, error) { } return created, nil } + +// GetNamespaceOptions transforms a slice of kernel namespaces +// into a slice of pod create options. Currently, not all +// kernel namespaces are supported, and they will be returned in an error +func GetNamespaceOptions(ns []string) ([]libpod.PodCreateOption, error) { + var options []libpod.PodCreateOption + var erroredOptions []libpod.PodCreateOption + for _, toShare := range ns { + switch toShare { + case "net": + options = append(options, libpod.WithPodNet()) + case "mnt": + //options = append(options, libpod.WithPodMNT()) + return erroredOptions, errors.Errorf("Mount sharing functionality not supported on pod level") + case "pid": + options = append(options, libpod.WithPodPID()) + case "user": + // Note: more set up needs to be done before this doesn't error out a create. + return erroredOptions, errors.Errorf("User sharing functionality not supported on pod level") + case "ipc": + options = append(options, libpod.WithPodIPC()) + case "uts": + options = append(options, libpod.WithPodUTS()) + case "": + case "none": + return erroredOptions, nil + default: + return erroredOptions, errors.Errorf("Invalid kernel namespace to share: %s. Options are: net, pid, ipc, uts or none", toShare) + } + } + return options, nil +} -- cgit v1.2.3-54-g00ecf