Introduce singularNameProvider for core types

This introduces `singularNameProvider`. This provider will be used
by core types to have their singular names are defined in discovery
endpoint. Thanks to that, core resources singular name always have
higher precedence than CRDs shortcuts or singular names.
This commit is contained in:
Arda Güçlü
2022-11-02 12:53:56 +03:00
parent ab376e09dd
commit 0990ba1cc9
65 changed files with 501 additions and 1 deletions

View File

@@ -291,6 +291,13 @@ func (r *REST) ShortNames() []string {
return []string{"ns"}
}
var _ rest.SingularNameProvider = &REST{}
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
func (r *REST) SingularName() string {
return "namespace"
}
var _ rest.StorageVersionProvider = &REST{}
func (r *REST) StorageVersion() runtime.GroupVersioner {

View File

@@ -628,3 +628,11 @@ func TestShortNames(t *testing.T) {
expected := []string{"ns"}
registrytest.AssertShortNames(t, storage, expected)
}
func TestSingularName(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.store.DestroyFunc()
expected := "namespace"
registrytest.AssertSingularName(t, storage, expected)
}