make RESTMapper.KindFor

This commit is contained in:
deads2k
2015-11-16 15:14:27 -05:00
parent 581a1ad1af
commit 5c4fb5bcbe
11 changed files with 41 additions and 69 deletions

View File

@@ -22,6 +22,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/unversioned"
)
const kubectlAnnotationPrefix = "kubectl.kubernetes.io/"
@@ -65,12 +66,13 @@ type ShortcutExpander struct {
meta.RESTMapper
}
// VersionAndKindForResource implements meta.RESTMapper. It expands the resource first, then invokes the wrapped
var _ meta.RESTMapper = &ShortcutExpander{}
// KindFor implements meta.RESTMapper. It expands the resource first, then invokes the wrapped
// mapper.
func (e ShortcutExpander) VersionAndKindForResource(resource string) (defaultVersion, kind string, err error) {
func (e ShortcutExpander) KindFor(resource string) (unversioned.GroupVersionKind, error) {
resource = expandResourceShortcut(resource)
defaultVersion, kind, err = e.RESTMapper.VersionAndKindForResource(resource)
return defaultVersion, kind, err
return e.RESTMapper.KindFor(resource)
}
// ResourceIsValid takes a string (kind) and checks if it's a valid resource.