diff --git a/pkg/registry/core/node/storage/storage.go b/pkg/registry/core/node/storage/storage.go index 5b6ce5eb0af..912dcb84171 100644 --- a/pkg/registry/core/node/storage/storage.go +++ b/pkg/registry/core/node/storage/storage.go @@ -168,9 +168,6 @@ func (r *REST) ResourceLocation(ctx context.Context, id string) (*url.URL, http. return node.ResourceLocation(r, r.connection, r.proxyTransport, ctx, id) } -// Implement ShortNamesProvider -var _ rest.ShortNamesProvider = &REST{} - // ShortNames implements the ShortNamesProvider interface. Returns a list of short names for a resource. func (r *REST) ShortNames() []string { return []string{"no"} diff --git a/pkg/registry/core/pod/storage/storage.go b/pkg/registry/core/pod/storage/storage.go index 0109c643bdf..723ef4778e9 100644 --- a/pkg/registry/core/pod/storage/storage.go +++ b/pkg/registry/core/pod/storage/storage.go @@ -290,7 +290,7 @@ func (r *LegacyBindingREST) Create(ctx context.Context, obj runtime.Object, crea } func (r *LegacyBindingREST) GetSingularName() string { - return "bindings" + return "binding" } // StatusREST implements the REST endpoint for changing the status of a pod. diff --git a/test/integration/apiserver/discovery/discovery_test.go b/test/integration/apiserver/discovery/discovery_test.go index c6b7caaa477..b27dbecb2b4 100644 --- a/test/integration/apiserver/discovery/discovery_test.go +++ b/test/integration/apiserver/discovery/discovery_test.go @@ -690,6 +690,33 @@ func TestGroupPriorty(t *testing.T) { }) } +func TestSingularNames(t *testing.T) { + server := kubeapiservertesting.StartTestServerOrDie(t, nil, []string{"--runtime-config=api/all=true"}, framework.SharedEtcd()) + t.Cleanup(server.TearDownFn) + + kubeClientSet, err := kubernetes.NewForConfig(server.ClientConfig) + require.NoError(t, err) + + _, resources, err := kubeClientSet.Discovery().ServerGroupsAndResources() + require.NoError(t, err) + + for _, rr := range resources { + for _, r := range rr.APIResources { + if strings.Contains(r.Name, "/") { + continue + } + if r.SingularName == "" { + t.Errorf("missing singularName for resource %q in %q", r.Name, rr.GroupVersion) + continue + } + if r.SingularName != strings.ToLower(r.Kind) { + t.Errorf("expected singularName for resource %q in %q to be %q, got %q", r.Name, rr.GroupVersion, strings.ToLower(r.Kind), r.SingularName) + continue + } + } + } +} + func makeCRDSpec(group string, kind string, namespaced bool, versions []string, categories ...string) apiextensionsv1.CustomResourceDefinitionSpec { scope := apiextensionsv1.NamespaceScoped if !namespaced {