expose discovery information on scalable resources
Kubernetes-commit: 65d0f188f68f6428ccc0a776adff496d972faa56
This commit is contained in:
parent
0b878bfae2
commit
56e7f5b9c2
|
|
@ -378,20 +378,8 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||||
resourceKind = kind
|
resourceKind = kind
|
||||||
}
|
}
|
||||||
|
|
||||||
var shortNames []string
|
|
||||||
shortNamesProvider, ok := storage.(rest.ShortNamesProvider)
|
|
||||||
if ok {
|
|
||||||
shortNames = shortNamesProvider.ShortNames()
|
|
||||||
}
|
|
||||||
|
|
||||||
tableProvider, _ := storage.(rest.TableConvertor)
|
tableProvider, _ := storage.(rest.TableConvertor)
|
||||||
|
|
||||||
var categories []string
|
|
||||||
categoriesProvider, ok := storage.(rest.CategoriesProvider)
|
|
||||||
if ok {
|
|
||||||
categories = categoriesProvider.Categories()
|
|
||||||
}
|
|
||||||
|
|
||||||
var apiResource metav1.APIResource
|
var apiResource metav1.APIResource
|
||||||
// Get the list of actions for the given scope.
|
// Get the list of actions for the given scope.
|
||||||
switch scope.Name() {
|
switch scope.Name() {
|
||||||
|
|
@ -867,8 +855,19 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||||
apiResource.Verbs = append(apiResource.Verbs, kubeVerb)
|
apiResource.Verbs = append(apiResource.Verbs, kubeVerb)
|
||||||
}
|
}
|
||||||
sort.Strings(apiResource.Verbs)
|
sort.Strings(apiResource.Verbs)
|
||||||
apiResource.ShortNames = shortNames
|
|
||||||
apiResource.Categories = categories
|
if shortNamesProvider, ok := storage.(rest.ShortNamesProvider); ok {
|
||||||
|
apiResource.ShortNames = shortNamesProvider.ShortNames()
|
||||||
|
}
|
||||||
|
if categoriesProvider, ok := storage.(rest.CategoriesProvider); ok {
|
||||||
|
apiResource.Categories = categoriesProvider.Categories()
|
||||||
|
}
|
||||||
|
if gvkProvider, ok := storage.(rest.GroupVersionKindProvider); ok {
|
||||||
|
gvk := gvkProvider.GroupVersionKind()
|
||||||
|
apiResource.Group = gvk.Group
|
||||||
|
apiResource.Version = gvk.Version
|
||||||
|
apiResource.Kind = gvk.Kind
|
||||||
|
}
|
||||||
|
|
||||||
return &apiResource, nil
|
return &apiResource, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,14 @@ type CategoriesProvider interface {
|
||||||
Categories() []string
|
Categories() []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GroupVersionKindProvider is used to specify a particular GroupVersionKind to discovery. This is used for polymorphic endpoints
|
||||||
|
// which generally point to foreign versions. Scale refers to Scale.v1beta1.extensions for instance.
|
||||||
|
// This trumps KindProvider since it is capable of providing the information required.
|
||||||
|
// TODO KindProvider (only used by federation) should be removed and replaced with this, but that presents greater risk late in 1.8.
|
||||||
|
type GroupVersionKindProvider interface {
|
||||||
|
GroupVersionKind() schema.GroupVersionKind
|
||||||
|
}
|
||||||
|
|
||||||
// Lister is an object that can retrieve resources that match the provided field and label criteria.
|
// Lister is an object that can retrieve resources that match the provided field and label criteria.
|
||||||
type Lister interface {
|
type Lister interface {
|
||||||
// NewList returns an empty object that can be used with the List call.
|
// NewList returns an empty object that can be used with the List call.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue