fix --local panic in set commands

This commit is contained in:
juanvallejo
2018-06-29 10:36:44 -04:00
parent 98de0729cf
commit e8df247597
6 changed files with 25 additions and 7 deletions

View File

@@ -24,6 +24,7 @@ import (
"net/url"
"os"
"path/filepath"
"strings"
"time"
"golang.org/x/text/encoding/unicode"
@@ -141,6 +142,18 @@ func (i *Info) Refresh(obj runtime.Object, ignoreError bool) error {
return nil
}
// ObjectName returns an approximate form of the resource's kind/name.
func (i *Info) ObjectName() string {
if i.Mapping != nil {
return fmt.Sprintf("%s/%s", i.Mapping.Resource.Resource, i.Name)
}
gvk := i.Object.GetObjectKind().GroupVersionKind()
if len(gvk.Group) == 0 {
return fmt.Sprintf("%s/%s", strings.ToLower(gvk.Kind), i.Name)
}
return fmt.Sprintf("%s.%s/%s\n", strings.ToLower(gvk.Kind), gvk.Group, i.Name)
}
// String returns the general purpose string representation
func (i *Info) String() string {
basicInfo := fmt.Sprintf("Name: %q, Namespace: %q\nObject: %+q", i.Name, i.Namespace, i.Object)