Revert "Scopes: Add more BE filtering (field selectors) (#85169)" (#85264)

This reverts commit 222f93794d.
This commit is contained in:
Kyle Brandt
2024-03-27 09:47:48 -04:00
committed by GitHub
parent 3049acd7d7
commit fe209fdf7c
2 changed files with 8 additions and 32 deletions

View File

@@ -54,7 +54,7 @@ func (b *ScopeAPIBuilder) InstallSchema(scheme *runtime.Scheme) error {
err = scheme.AddFieldLabelConversionFunc(
scope.ScopeResourceInfo.GroupVersionKind(),
func(label, value string) (string, string, error) {
fieldSet := SelectableScopeFields(&scope.Scope{})
fieldSet := SelectableFields(&scope.Scope{})
for key := range fieldSet {
if label == key {
return label, value, nil
@@ -67,22 +67,6 @@ func (b *ScopeAPIBuilder) InstallSchema(scheme *runtime.Scheme) error {
return err
}
err = scheme.AddFieldLabelConversionFunc(
scope.ScopeDashboardResourceInfo.GroupVersionKind(),
func(label, value string) (string, string, error) {
fieldSet := SelectableScopeDashboardFields(&scope.ScopeDashboard{})
for key := range fieldSet {
if label == key {
return label, value, nil
}
}
return "", "", fmt.Errorf("field label not supported for %s: %s", scope.ScopeDashboardResourceInfo.GroupVersionKind(), label)
},
)
if err != nil {
return err
}
// Link this version to the internal representation.
// This is used for server-side-apply (PATCH), and avoids the error:
// "no kind is registered for the type"

View File

@@ -101,13 +101,12 @@ func newScopeDashboardStorage(scheme *runtime.Scheme, optsGetter generic.RESTOpt
}
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
if s, ok := obj.(*scope.Scope); ok {
return labels.Set(s.Labels), SelectableScopeFields(s), nil
s, ok := obj.(*scope.Scope)
if !ok {
return nil, nil, fmt.Errorf("not a scope")
}
if s, ok := obj.(*scope.ScopeDashboard); ok {
return labels.Set(s.Labels), SelectableScopeDashboardFields(s), nil
}
return nil, nil, fmt.Errorf("not a scope or scopeDashboard object")
return labels.Set(s.Labels), SelectableFields(s), nil
}
// Matcher returns a generic.SelectionPredicate that matches on label and field selectors.
@@ -119,15 +118,8 @@ func Matcher(label labels.Selector, field fields.Selector) apistore.SelectionPre
}
}
func SelectableScopeFields(obj *scope.Scope) fields.Set {
func SelectableFields(obj *scope.Scope) fields.Set {
return generic.MergeFieldsSets(generic.ObjectMetaFieldsSet(&obj.ObjectMeta, false), fields.Set{
"spec.type": obj.Spec.Type,
"spec.category": obj.Spec.Category,
})
}
func SelectableScopeDashboardFields(obj *scope.ScopeDashboard) fields.Set {
return generic.MergeFieldsSets(generic.ObjectMetaFieldsSet(&obj.ObjectMeta, false), fields.Set{
"spec.scopeUid": obj.Spec.ScopeUID,
"spec.type": obj.Spec.Type,
})
}