29
vendor/k8s.io/apiserver/pkg/storage/selection_predicate.go
generated
vendored
29
vendor/k8s.io/apiserver/pkg/storage/selection_predicate.go
generated
vendored
@@ -74,6 +74,7 @@ type SelectionPredicate struct {
|
||||
Label labels.Selector
|
||||
Field fields.Selector
|
||||
GetAttrs AttrFunc
|
||||
IndexLabels []string
|
||||
IndexFields []string
|
||||
Limit int64
|
||||
Continue string
|
||||
@@ -128,3 +129,31 @@ func (s *SelectionPredicate) MatchesSingle() (string, bool) {
|
||||
func (s *SelectionPredicate) Empty() bool {
|
||||
return s.Label.Empty() && s.Field.Empty()
|
||||
}
|
||||
|
||||
// For any index defined by IndexFields, if a matcher can match only (a subset)
|
||||
// of objects that return <value> for a given index, a pair (<index name>, <value>)
|
||||
// wil be returned.
|
||||
func (s *SelectionPredicate) MatcherIndex() []MatchValue {
|
||||
var result []MatchValue
|
||||
for _, field := range s.IndexFields {
|
||||
if value, ok := s.Field.RequiresExactMatch(field); ok {
|
||||
result = append(result, MatchValue{IndexName: FieldIndex(field), Value: value})
|
||||
}
|
||||
}
|
||||
for _, label := range s.IndexLabels {
|
||||
if value, ok := s.Label.RequiresExactMatch(label); ok {
|
||||
result = append(result, MatchValue{IndexName: LabelIndex(label), Value: value})
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// LabelIndex add prefix for label index.
|
||||
func LabelIndex(label string) string {
|
||||
return "l:" + label
|
||||
}
|
||||
|
||||
// FiledIndex add prefix for field index.
|
||||
func FieldIndex(field string) string {
|
||||
return "f:" + field
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user