aboutsummaryrefslogtreecommitdiff
path: root/pkg/util
diff options
context:
space:
mode:
authorPaul Holzinger <paul.holzinger@web.de>2020-11-17 16:43:17 +0100
committerPaul Holzinger <paul.holzinger@web.de>2020-11-18 11:36:06 +0100
commit4f427a89cbc0814c25dd4b562ddf4ff4e568a005 (patch)
tree0a0b18c76a96649e0a3482efe2c2b76514dd1a23 /pkg/util
parent3502860e1cfe1042aca7a8de8446360662a5a2fd (diff)
downloadpodman-4f427a89cbc0814c25dd4b562ddf4ff4e568a005.tar.gz
podman-4f427a89cbc0814c25dd4b562ddf4ff4e568a005.tar.bz2
podman-4f427a89cbc0814c25dd4b562ddf4ff4e568a005.zip
Align the podman ps --filter behavior with docker
All of our filters worked exclusive resulting in `--filter status=created --filter status=exited` to return nothing. In docker filters with the same key work inclusive with the only exception being `label` which is exclusive. Filters with different keys always work exclusive. This PR aims to match the docker behavior with podman. Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'pkg/util')
-rw-r--r--pkg/util/utils.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/pkg/util/utils.go b/pkg/util/utils.go
index 415fd169b..f6a084c00 100644
--- a/pkg/util/utils.go
+++ b/pkg/util/utils.go
@@ -6,6 +6,7 @@ import (
"os"
"os/user"
"path/filepath"
+ "regexp"
"strconv"
"strings"
"sync"
@@ -84,6 +85,17 @@ func StringInSlice(s string, sl []string) bool {
return false
}
+// StringMatchRegexSlice determines if a given string matches one of the given regexes, returns bool
+func StringMatchRegexSlice(s string, re []string) bool {
+ for _, r := range re {
+ m, err := regexp.MatchString(r, s)
+ if err == nil && m {
+ return true
+ }
+ }
+ return false
+}
+
// ImageConfig is a wrapper around the OCIv1 Image Configuration struct exported
// by containers/image, but containing additional fields that are not supported
// by OCIv1 (but are by Docker v2) - notably OnBuild.