mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-19 00:19:14 +00:00
Merge pull request #30529 from hongchaodeng/r1
Automatic merge from submit-queue change all PredicateFunc to use SelectionPredicate What? - This PR changes all PredicateFunc in registry to return SelectionPredicate instead of Matcher interface. Why? - We want to pass SelectionPredicate to storage layer. Matcher interface did not expose enough information for indexing.
This commit is contained in:
@@ -17,6 +17,8 @@ limitations under the License.
|
||||
package rest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/test_apis/testgroup.k8s.io"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/fields"
|
||||
@@ -59,8 +61,18 @@ func NewREST(config *storagebackend.Config, storageDecorator generic.StorageDeco
|
||||
return obj.(*testgroup.TestType).Name, nil
|
||||
},
|
||||
// Used to match objects based on labels/fields for list.
|
||||
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
|
||||
return generic.MatcherFunc(nil)
|
||||
PredicateFunc: func(label labels.Selector, field fields.Selector) *generic.SelectionPredicate {
|
||||
return &generic.SelectionPredicate{
|
||||
Label: label,
|
||||
Field: field,
|
||||
GetAttrs: func(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||
testType, ok := obj.(*testgroup.TestType)
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("unexpected type of given object")
|
||||
}
|
||||
return labels.Set(testType.ObjectMeta.Labels), fields.Set{}, nil
|
||||
},
|
||||
}
|
||||
},
|
||||
Storage: storageInterface,
|
||||
}
|
||||
|
Reference in New Issue
Block a user