summaryrefslogtreecommitdiff
path: root/libpod/options.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-06-25 10:35:15 -0400
committerMatthew Heon <matthew.heon@gmail.com>2018-07-24 16:12:31 -0400
commit24457873366bbd23d71b364a63037f34c652c04a (patch)
tree407f9b00b003c4baf0e577008a803a5d06c5dd03 /libpod/options.go
parent6715bffaf6a858df9539d6e48e2c1b634364f83e (diff)
downloadpodman-24457873366bbd23d71b364a63037f34c652c04a.tar.gz
podman-24457873366bbd23d71b364a63037f34c652c04a.tar.bz2
podman-24457873366bbd23d71b364a63037f34c652c04a.zip
Add container and pod namespaces to configs
Libpod namespaces are a way to logically separate groups of pods and containers within the state. Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Diffstat (limited to 'libpod/options.go')
-rw-r--r--libpod/options.go41
1 files changed, 38 insertions, 3 deletions
diff --git a/libpod/options.go b/libpod/options.go
index 718b44930..fb07d1edf 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -388,8 +388,9 @@ func WithStdin() CtrCreateOption {
}
// WithPod adds the container to a pod.
-// Containers which join a pod can only join the namespaces of other containers
-// in the same pod.
+// Containers which join a pod can only join the Linux namespaces of other
+// containers in the same pod.
+// Containers can only join pods in the same libpod namespace.
func (r *Runtime) WithPod(pod *Pod) CtrCreateOption {
return func(ctr *Container) error {
if ctr.valid {
@@ -944,7 +945,8 @@ func WithCommand(command []string) CtrCreateOption {
}
}
-// WithRootFS sets the rootfs for the container
+// WithRootFS sets the rootfs for the container.
+// This creates a container from a directory on disk and not an image.
func WithRootFS(rootfs string) CtrCreateOption {
return func(ctr *Container) error {
if ctr.valid {
@@ -961,6 +963,22 @@ func WithRootFS(rootfs string) CtrCreateOption {
}
}
+// WithNamespace sets the namespace the container will be created in.
+// Namespaces are used to create separate views of Podman's state - runtimes can
+// join a specific namespace and see only containers and pods in that namespace.
+// Empty string namespaces are allowed, and correspond to a lack of namespace.
+func WithNamespace(ns string) CtrCreateOption {
+ return func(ctr *Container) error {
+ if ctr.valid {
+ return ErrCtrFinalized
+ }
+
+ ctr.config.Namespace = ns
+
+ return nil
+ }
+}
+
// Pod Creation Options
// WithPodName sets the name of the pod.
@@ -1025,3 +1043,20 @@ func WithPodCgroups() PodCreateOption {
return nil
}
}
+
+// WithPodNamespace sets the namespace for the created pod.
+// Namespaces are used to create separate views of Podman's state - runtimes can
+// join a specific namespace and see only containers and pods in that namespace.
+// Empty string namespaces are allowed, and correspond to a lack of namespace.
+// Containers must belong to the same namespace as the pod they join.
+func WithPodNamespace(ns string) PodCreateOption {
+ return func(pod *Pod) error {
+ if pod.valid {
+ return ErrPodFinalized
+ }
+
+ pod.config.Namespace = ns
+
+ return nil
+ }
+}