summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-12-23 04:42:30 -0500
committerGitHub <noreply@github.com>2020-12-23 04:42:30 -0500
commit767e1ac17fe093b1c1bf7525e95dd162c55a490a (patch)
treeff4605818e6ac237ab0efefd645599220831b88a /libpod
parent9b6324f51f7279683f2d2a6c90542029e1ded1ee (diff)
parentc50c75419b80791d6dd086ced608c41b2f3d96b6 (diff)
downloadpodman-767e1ac17fe093b1c1bf7525e95dd162c55a490a.tar.gz
podman-767e1ac17fe093b1c1bf7525e95dd162c55a490a.tar.bz2
podman-767e1ac17fe093b1c1bf7525e95dd162c55a490a.zip
Merge pull request #8804 from baude/issue8512
add pod filter for ps
Diffstat (limited to 'libpod')
-rw-r--r--libpod/filters/containers.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/libpod/filters/containers.go b/libpod/filters/containers.go
index 2520c4f30..505429de6 100644
--- a/libpod/filters/containers.go
+++ b/libpod/filters/containers.go
@@ -203,6 +203,37 @@ func GenerateContainerFilterFuncs(filter string, filterValues []string, r *libpo
}
return false
}, nil
+ case "pod":
+ var pods []*libpod.Pod
+ for _, podNameOrID := range filterValues {
+ p, err := r.LookupPod(podNameOrID)
+ if err != nil {
+ if errors.Cause(err) == define.ErrNoSuchPod {
+ continue
+ }
+ return nil, err
+ }
+ pods = append(pods, p)
+ }
+ return func(c *libpod.Container) bool {
+ // if no pods match, quick out
+ if len(pods) < 1 {
+ return false
+ }
+ // if the container has no pod id, quick out
+ if len(c.PodID()) < 1 {
+ return false
+ }
+ for _, p := range pods {
+ // we already looked up by name or id, so id match
+ // here is ok
+ if p.ID() == c.PodID() {
+ return true
+ }
+ }
+ return false
+ }, nil
+
}
return nil, errors.Errorf("%s is an invalid filter", filter)
}