summaryrefslogtreecommitdiff
path: root/libpod/container.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-01-16 13:26:09 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-01-17 15:26:43 +0000
commitaa34b86ae601398a3abac0ee70ed9a4ea96187c3 (patch)
treece191238824a3c78a96e06803b8b26e9f68986fe /libpod/container.go
parentdaba9836c8f6c31b548248c0938091e684c3d592 (diff)
downloadpodman-aa34b86ae601398a3abac0ee70ed9a4ea96187c3.tar.gz
podman-aa34b86ae601398a3abac0ee70ed9a4ea96187c3.tar.bz2
podman-aa34b86ae601398a3abac0ee70ed9a4ea96187c3.zip
Add ability to get dependencies of a container
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #229 Approved by: rhatdan
Diffstat (limited to 'libpod/container.go')
-rw-r--r--libpod/container.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/libpod/container.go b/libpod/container.go
index 95c7eecb4..4d6fe3a5e 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -310,6 +310,40 @@ func (c *Container) ProcessLabel() string {
return c.config.ProcessLabel
}
+// Dependencies gets the containers this container depends upon
+func (c *Container) Dependencies() []string {
+ // Collect in a map first to remove dupes
+ dependsCtrs := map[string]bool{}
+ if c.config.IPCNsCtr != "" {
+ dependsCtrs[c.config.IPCNsCtr] = true
+ }
+ if c.config.MountNsCtr != "" {
+ dependsCtrs[c.config.MountNsCtr] = true
+ }
+ if c.config.NetNsCtr != "" {
+ dependsCtrs[c.config.NetNsCtr] = true
+ }
+ if c.config.PIDNsCtr != "" {
+ dependsCtrs[c.config.NetNsCtr] = true
+ }
+ if c.config.UserNsCtr != "" {
+ dependsCtrs[c.config.UserNsCtr] = true
+ }
+ if c.config.UTSNsCtr != "" {
+ dependsCtrs[c.config.UTSNsCtr] = true
+ }
+ if c.config.CgroupNsCtr != "" {
+ dependsCtrs[c.config.CgroupNsCtr] = true
+ }
+
+ depends := make([]string, len(dependsCtrs), 0)
+ for ctr, _ := range dependsCtrs {
+ depends = append(depends, ctr)
+ }
+
+ return depends
+}
+
// Spec returns the container's OCI runtime spec
// The spec returned is the one used to create the container. The running
// spec may differ slightly as mounts are added based on the image