mirror of
https://github.com/containers/podman
synced 2024-10-22 02:03:38 +00:00
Add ability to get dependencies of a container
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #229 Approved by: rhatdan
This commit is contained in:
parent
daba9836c8
commit
aa34b86ae6
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue