summaryrefslogtreecommitdiff
path: root/cmd/podman/ps.go
diff options
context:
space:
mode:
authorJoshua Roys <Joshua.Roys@gtri.gatech.edu>2018-07-16 10:36:57 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-07-16 18:27:02 +0000
commitea5fad6c8b35d73f6cc16642bc56f428954aa36e (patch)
treeee53e021e45c0a75bd285a1c70c44c0b46d18cf8 /cmd/podman/ps.go
parent6372c977ea0e6206d137e734a981ca0bb3435e12 (diff)
downloadpodman-ea5fad6c8b35d73f6cc16642bc56f428954aa36e.tar.gz
podman-ea5fad6c8b35d73f6cc16642bc56f428954aa36e.tar.bz2
podman-ea5fad6c8b35d73f6cc16642bc56f428954aa36e.zip
Fix ps filter with key=value labels
Closes: #1101 Approved by: rhatdan
Diffstat (limited to 'cmd/podman/ps.go')
-rw-r--r--cmd/podman/ps.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go
index 8cec73b3c..f795ee278 100644
--- a/cmd/podman/ps.go
+++ b/cmd/podman/ps.go
@@ -235,7 +235,7 @@ func psCmd(c *cli.Context) error {
if opts.Filter != "" {
filters := strings.Split(opts.Filter, ",")
for _, f := range filters {
- filterSplit := strings.Split(f, "=")
+ filterSplit := strings.SplitN(f, "=", 2)
if len(filterSplit) < 2 {
return errors.Errorf("filter input must be in the form of filter=value: %s is invalid", f)
}
@@ -303,9 +303,16 @@ func generateContainerFilterFuncs(filter, filterValue string, runtime *libpod.Ru
return strings.Contains(c.ID(), filterValue)
}, nil
case "label":
+ var filterArray []string = strings.Split(filterValue, "=")
+ var filterKey string = filterArray[0]
+ if len(filterArray) > 1 {
+ filterValue = filterArray[1]
+ } else {
+ filterValue = ""
+ }
return func(c *libpod.Container) bool {
- for _, label := range c.Labels() {
- if label == filterValue {
+ for labelKey, labelValue := range c.Labels() {
+ if labelKey == filterKey && ("" == filterValue || labelValue == filterValue) {
return true
}
}