summaryrefslogtreecommitdiff
path: root/libpod/util.go
diff options
context:
space:
mode:
authorhaircommander <pehunt@redhat.com>2018-08-23 13:33:10 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-23 18:16:28 +0000
commit4c00dc66dfacc214d6fff845b73a4fc4226b6747 (patch)
tree38bb31acffd27a56a68f54af4968a082ffdb1f73 /libpod/util.go
parent0e6266858a913ac36de0726ede10d5d03af533e3 (diff)
downloadpodman-4c00dc66dfacc214d6fff845b73a4fc4226b6747.tar.gz
podman-4c00dc66dfacc214d6fff845b73a4fc4226b6747.tar.bz2
podman-4c00dc66dfacc214d6fff845b73a4fc4226b6747.zip
Refactor error checking in With*NSFromPod options
Signed-off-by: haircommander <pehunt@redhat.com> Closes: #1187 Approved by: mheon
Diffstat (limited to 'libpod/util.go')
-rw-r--r--libpod/util.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/libpod/util.go b/libpod/util.go
index 13235059f..17325f6e4 100644
--- a/libpod/util.go
+++ b/libpod/util.go
@@ -145,3 +145,18 @@ func sortMounts(m []spec.Mount) []spec.Mount {
sort.Sort(byDestination(m))
return m
}
+
+func validPodNSOption(p *Pod, ctrPod string) error {
+ if p == nil {
+ return errors.Wrapf(ErrInvalidArg, "pod passed in was nil. Container may not be associated with a pod")
+ }
+
+ if ctrPod == "" {
+ return errors.Wrapf(ErrInvalidArg, "container is not a member of any pod")
+ }
+
+ if ctrPod != p.ID() {
+ return errors.Wrapf(ErrInvalidArg, "pod passed in is not the pod the container is associated with")
+ }
+ return nil
+}