update -o name format to kind.group/name

This commit is contained in:
juanvallejo
2018-02-05 11:21:00 -05:00
parent 76e6da25fa
commit 765f9ec68b
17 changed files with 178 additions and 62 deletions

View File

@@ -598,10 +598,27 @@ func (b *Builder) SingleResourceType() *Builder {
return b
}
// mappingFor returns the RESTMapping for the Kind referenced by the resource.
// prefers a fully specified GroupVersionResource match. If we don't have one match on GroupResource
func (b *Builder) mappingFor(resourceArg string) (*meta.RESTMapping, error) {
fullySpecifiedGVR, groupResource := schema.ParseResourceArg(resourceArg)
// mappingFor returns the RESTMapping for the Kind given, or the Kind referenced by the resource.
// prefers a fully specified GroupVersionKind match. If we don't have one, match on a fully specified
// GroupVersionResource, or fallback to a match on GroupResource.
func (b *Builder) mappingFor(resourceOrKindArg string) (*meta.RESTMapping, error) {
fullySpecifiedGVK, groupKind := schema.ParseKindArg(resourceOrKindArg)
if fullySpecifiedGVK == nil {
gvk := groupKind.WithVersion("")
fullySpecifiedGVK = &gvk
}
if !fullySpecifiedGVK.Empty() {
if mapping, err := b.mapper.RESTMapping(fullySpecifiedGVK.GroupKind(), fullySpecifiedGVK.Version); err == nil {
return mapping, nil
} else {
if mapping, err := b.mapper.RESTMapping(groupKind, ""); err == nil {
return mapping, nil
}
}
}
fullySpecifiedGVR, groupResource := schema.ParseResourceArg(resourceOrKindArg)
gvk := schema.GroupVersionKind{}
if fullySpecifiedGVR != nil {
gvk, _ = b.mapper.KindFor(*fullySpecifiedGVR)