added short names for resources which are exposed during discovery
This commit is contained in:
parent
90dc6e098c
commit
8dc243803d
|
@ -35,10 +35,10 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apiserver/pkg/endpoints/handlers"
|
||||
"k8s.io/apiserver/pkg/endpoints/handlers/negotiation"
|
||||
"k8s.io/apiserver/pkg/endpoints/metrics"
|
||||
"k8s.io/apiserver/pkg/endpoints/request"
|
||||
"k8s.io/apiserver/pkg/endpoints/handlers"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
|
||||
"github.com/emicklei/go-restful"
|
||||
|
@ -368,6 +368,12 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
|||
resourceKind = kind
|
||||
}
|
||||
|
||||
var shortNames []string
|
||||
shortNamesProvider, ok := storage.(rest.ShortNamesProvider)
|
||||
if ok {
|
||||
shortNames = shortNamesProvider.ShortNames()
|
||||
}
|
||||
|
||||
var apiResource metav1.APIResource
|
||||
// Get the list of actions for the given scope.
|
||||
switch scope.Name() {
|
||||
|
@ -796,6 +802,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
|||
apiResource.Verbs = append(apiResource.Verbs, kubeVerb)
|
||||
}
|
||||
sort.Strings(apiResource.Verbs)
|
||||
apiResource.ShortNames = shortNames
|
||||
|
||||
return &apiResource, nil
|
||||
}
|
||||
|
|
|
@ -65,6 +65,11 @@ type KindProvider interface {
|
|||
Kind() string
|
||||
}
|
||||
|
||||
// ShortNamesProvider is an interface for RESTful storage services. Delivers a list of short names for a resource. The list is used by kubectl to have short names representation of resources.
|
||||
type ShortNamesProvider interface {
|
||||
ShortNames() []string
|
||||
}
|
||||
|
||||
// Lister is an object that can retrieve resources that match the provided field and label criteria.
|
||||
type Lister interface {
|
||||
// NewList returns an empty object that can be used with the List call.
|
||||
|
|
Loading…
Reference in New Issue