From 4f427a89cbc0814c25dd4b562ddf4ff4e568a005 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Tue, 17 Nov 2020 16:43:17 +0100 Subject: 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 --- pkg/util/utils.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'pkg/util') 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. -- cgit v1.2.3-54-g00ecf