diff options
Diffstat (limited to 'pkg/util/utils.go')
-rw-r--r-- | pkg/util/utils.go | 12 |
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. |