mirror of
https://github.com/containers/podman.git
synced 2025-12-06 13:56:22 +08:00
update c/{common,image,storage} to latest
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
21
vendor/github.com/containers/common/pkg/util/util.go
generated
vendored
21
vendor/github.com/containers/common/pkg/util/util.go
generated
vendored
@@ -6,6 +6,8 @@ import (
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/containers/common/libnetwork/types"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -110,3 +112,22 @@ func StringMatchRegexSlice(s string, re []string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// FilterID is a function used to compare an id against a set of ids, if the
|
||||
// input is hex we check if the prefix matches. Otherwise we assume it is a
|
||||
// regex and try to match that.
|
||||
// see https://github.com/containers/podman/issues/18471 for why we do this
|
||||
func FilterID(id string, filters []string) bool {
|
||||
for _, want := range filters {
|
||||
isRegex := types.NotHexRegex.MatchString(want)
|
||||
if isRegex {
|
||||
match, err := regexp.MatchString(want, id)
|
||||
if err == nil && match {
|
||||
return true
|
||||
}
|
||||
} else if strings.HasPrefix(id, strings.ToLower(want)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user