mirror of
https://github.com/containers/podman.git
synced 2025-10-18 11:42:55 +08:00
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:
34
vendor/github.com/containers/common/pkg/filters/filters.go
generated
vendored
34
vendor/github.com/containers/common/pkg/filters/filters.go
generated
vendored
@ -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)
|
||||
|
Reference in New Issue
Block a user