summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorJoel Smith <joelsmith@redhat.com>2020-11-03 14:59:03 -0700
committerJoel Smith <joelsmith@redhat.com>2020-11-03 15:31:39 -0700
commita47fe37a97b93911b4509636888018fa18de500d (patch)
treec99a9ce32ed005bd86a8b597d1e66d058c262ba7 /libpod
parent5f897d2abe960f2e29dd4ae87829c3c769a4423b (diff)
downloadpodman-a47fe37a97b93911b4509636888018fa18de500d.tar.gz
podman-a47fe37a97b93911b4509636888018fa18de500d.tar.bz2
podman-a47fe37a97b93911b4509636888018fa18de500d.zip
Use regex for "pod ps" name filter to match "ps" behavior
Signed-off-by: Joel Smith <joelsmith@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/filters/pods.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/libpod/filters/pods.go b/libpod/filters/pods.go
index adce9784c..0caa941dd 100644
--- a/libpod/filters/pods.go
+++ b/libpod/filters/pods.go
@@ -1,6 +1,7 @@
package lpfilters
import (
+ "regexp"
"strconv"
"strings"
@@ -78,7 +79,11 @@ func GeneratePodFilterFunc(filter, filterValue string) (
}, nil
case "name":
return func(p *libpod.Pod) bool {
- return strings.Contains(p.Name(), filterValue)
+ match, err := regexp.MatchString(filterValue, p.Name())
+ if err != nil {
+ return false
+ }
+ return match
}, nil
case "status":
if !util.StringInSlice(filterValue, []string{"stopped", "running", "paused", "exited", "dead", "created"}) {