fix(deps): update github.com/containers/common digest to e18cda8

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
renovate[bot]
2023-09-26 06:57:03 +00:00
committed by GitHub
parent a018fe7c1b
commit 5636d02192
4 changed files with 31 additions and 11 deletions

View File

@ -107,13 +107,7 @@ func PrepareFilters(r *http.Request) (map[string][]string, error) {
func MatchLabelFilters(filterValues []string, labels map[string]string) bool {
outer:
for _, filterValue := range filterValues {
filterArray := strings.SplitN(filterValue, "=", 2)
filterKey := filterArray[0]
if len(filterArray) > 1 {
filterValue = filterArray[1]
} else {
filterValue = ""
}
filterKey, filterValue := splitFilterValue(filterValue)
for labelKey, labelValue := range labels {
if filterValue == "" || labelValue == filterValue {
if labelKey == filterKey || matchPattern(filterKey, labelKey) {
@ -126,6 +120,32 @@ outer:
return true
}
// MatchNegatedLabelFilters matches negated labels and returns true if they are valid
func MatchNegatedLabelFilters(filterValues []string, labels map[string]string) bool {
for _, filterValue := range filterValues {
filterKey, filterValue := splitFilterValue(filterValue)
for labelKey, labelValue := range labels {
if filterValue == "" || labelValue == filterValue {
if labelKey == filterKey || matchPattern(filterKey, labelKey) {
return false
}
}
}
}
return true
}
func splitFilterValue(filterValue string) (string, string) {
filterArray := strings.SplitN(filterValue, "=", 2)
filterKey := filterArray[0]
if len(filterArray) > 1 {
filterValue = filterArray[1]
} else {
filterValue = ""
}
return filterKey, filterValue
}
func matchPattern(pattern string, value string) bool {
if strings.Contains(pattern, "*") {
filter := fmt.Sprintf("*%s*", pattern)