Reverting 18442
This commit is contained in:
@@ -23,7 +23,6 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/meta"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
)
|
||||
|
||||
const kubectlAnnotationPrefix = "kubectl.kubernetes.io/"
|
||||
@@ -81,40 +80,40 @@ var _ meta.RESTMapper = &ShortcutExpander{}
|
||||
|
||||
// KindFor implements meta.RESTMapper. It expands the resource first, then invokes the wrapped
|
||||
// mapper.
|
||||
func (e ShortcutExpander) KindFor(resource unversioned.GroupVersionResource) (unversioned.GroupVersionKind, error) {
|
||||
func (e ShortcutExpander) KindFor(resource string) (unversioned.GroupVersionKind, error) {
|
||||
resource = expandResourceShortcut(resource)
|
||||
return e.RESTMapper.KindFor(resource)
|
||||
}
|
||||
|
||||
// ResourceIsValid takes a string (kind) and checks if it's a valid resource.
|
||||
// It expands the resource first, then invokes the wrapped mapper.
|
||||
func (e ShortcutExpander) ResourceIsValid(resource unversioned.GroupVersionResource) bool {
|
||||
func (e ShortcutExpander) ResourceIsValid(resource string) bool {
|
||||
return e.RESTMapper.ResourceIsValid(expandResourceShortcut(resource))
|
||||
}
|
||||
|
||||
// expandResourceShortcut will return the expanded version of resource
|
||||
// (something that a pkg/api/meta.RESTMapper can understand), if it is
|
||||
// indeed a shortcut. Otherwise, will return resource unmodified.
|
||||
func expandResourceShortcut(resource unversioned.GroupVersionResource) unversioned.GroupVersionResource {
|
||||
shortForms := map[string]unversioned.GroupVersionResource{
|
||||
func expandResourceShortcut(resource string) string {
|
||||
shortForms := map[string]string{
|
||||
// Please keep this alphabetized
|
||||
"cs": api.SchemeGroupVersion.WithResource("componentstatuses"),
|
||||
"ds": extensions.SchemeGroupVersion.WithResource("daemonsets"),
|
||||
"ep": api.SchemeGroupVersion.WithResource("endpoints"),
|
||||
"ev": api.SchemeGroupVersion.WithResource("events"),
|
||||
"hpa": extensions.SchemeGroupVersion.WithResource("horizontalpodautoscalers"),
|
||||
"ing": extensions.SchemeGroupVersion.WithResource("ingresses"),
|
||||
"limits": api.SchemeGroupVersion.WithResource("limitranges"),
|
||||
"no": api.SchemeGroupVersion.WithResource("nodes"),
|
||||
"ns": api.SchemeGroupVersion.WithResource("namespaces"),
|
||||
"po": api.SchemeGroupVersion.WithResource("pods"),
|
||||
"pvc": api.SchemeGroupVersion.WithResource("persistentvolumeclaims"),
|
||||
"pv": api.SchemeGroupVersion.WithResource("persistentvolumes"),
|
||||
"quota": api.SchemeGroupVersion.WithResource("resourcequotas"),
|
||||
"rc": api.SchemeGroupVersion.WithResource("replicationcontrollers"),
|
||||
"svc": api.SchemeGroupVersion.WithResource("services"),
|
||||
"cs": "componentstatuses",
|
||||
"ds": "daemonsets",
|
||||
"ep": "endpoints",
|
||||
"ev": "events",
|
||||
"hpa": "horizontalpodautoscalers",
|
||||
"ing": "ingresses",
|
||||
"limits": "limitranges",
|
||||
"no": "nodes",
|
||||
"ns": "namespaces",
|
||||
"po": "pods",
|
||||
"pvc": "persistentvolumeclaims",
|
||||
"pv": "persistentvolumes",
|
||||
"quota": "resourcequotas",
|
||||
"rc": "replicationcontrollers",
|
||||
"svc": "services",
|
||||
}
|
||||
if expanded, ok := shortForms[resource.Resource]; ok {
|
||||
if expanded, ok := shortForms[resource]; ok {
|
||||
return expanded
|
||||
}
|
||||
return resource
|
||||
|
Reference in New Issue
Block a user