Scopes: Add Filtering for ScopeDashoardBinding and Update Prometheus for ScopeFilterOperator Changes (#85284)
This commit is contained in:
@@ -80,11 +80,22 @@ type ScopeSpec struct {
|
||||
// ScopeFilter is a hand copy of the ScopeFilter struct from pkg/apis/scope/v0alpha1/types.go
|
||||
// to avoid import (temp fix)
|
||||
type ScopeFilter struct {
|
||||
Key string `json:"key"`
|
||||
Value string `json:"value"`
|
||||
Operator string `json:"operator"`
|
||||
Key string `json:"key"`
|
||||
Value string `json:"value"`
|
||||
Operator FilterOperator `json:"operator"`
|
||||
}
|
||||
|
||||
// FilterOperator is a hand copy of the ScopeFilter struct from pkg/apis/scope/v0alpha1/types.go
|
||||
type FilterOperator string
|
||||
|
||||
// Hand copy of enum from pkg/apis/scope/v0alpha1/types.go
|
||||
const (
|
||||
FilterOperatorEquals FilterOperator = "equals"
|
||||
FilterOperatorNotEquals FilterOperator = "not-equals"
|
||||
FilterOperatorRegexMatch FilterOperator = "regex-match"
|
||||
FilterOperatorRegexNotMatch FilterOperator = "regex-not-match"
|
||||
)
|
||||
|
||||
// Internal interval and range variables
|
||||
const (
|
||||
varInterval = "$__interval"
|
||||
|
||||
@@ -63,13 +63,13 @@ func scopeFiltersToMatchers(filters []ScopeFilter) ([]*labels.Matcher, error) {
|
||||
for _, f := range filters {
|
||||
var mt labels.MatchType
|
||||
switch f.Operator {
|
||||
case "=":
|
||||
case FilterOperatorEquals:
|
||||
mt = labels.MatchEqual
|
||||
case "!=":
|
||||
case FilterOperatorNotEquals:
|
||||
mt = labels.MatchNotEqual
|
||||
case "=~":
|
||||
case FilterOperatorRegexMatch:
|
||||
mt = labels.MatchRegexp
|
||||
case "!~":
|
||||
case FilterOperatorRegexNotMatch:
|
||||
mt = labels.MatchNotRegexp
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown operator %q", f.Operator)
|
||||
|
||||
Reference in New Issue
Block a user