diff --git a/pkg/registry/apis/scope/register.go b/pkg/registry/apis/scope/register.go index 56503f6a427..f5f1a64936d 100644 --- a/pkg/registry/apis/scope/register.go +++ b/pkg/registry/apis/scope/register.go @@ -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" diff --git a/pkg/registry/apis/scope/storage.go b/pkg/registry/apis/scope/storage.go index 4dadb8ede8b..d033892994a 100644 --- a/pkg/registry/apis/scope/storage.go +++ b/pkg/registry/apis/scope/storage.go @@ -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, }) }