@@ -67,24 +67,32 @@ func run(_ *cobra.Command, args []string) error {
6767
6868 kind , name := args [0 ], args [1 ]
6969 klog .V (3 ).Infof ("parsed kind=%v name=%v" , kind , name )
70- apiRes := apis .lookup (kind )
71- klog .V (5 ).Infof ("kind matches=%v" , apiRes )
72- if len (apiRes ) == 0 {
73- return fmt .Errorf ("could not find api kind %q" , kind )
74- } else if len (apiRes ) > 1 {
75- names := make ([]string , 0 , len (apiRes ))
76- for _ , a := range apiRes {
77- names = append (names , fullAPIName (a ))
70+
71+ var api apiResource
72+ if k , ok := overrideType (kind , apis ); ok {
73+ klog .V (2 ).Infof ("kind=%s override found: %s" , k .GroupVersionResource ())
74+ api = k
75+ } else {
76+ apiResults := apis .lookup (kind )
77+ klog .V (5 ).Infof ("kind matches=%v" , apiResults )
78+ if len (apiResults ) == 0 {
79+ return fmt .Errorf ("could not find api kind %q" , kind )
80+ } else if len (apiResults ) > 1 {
81+ names := make ([]string , 0 , len (apiResults ))
82+ for _ , a := range apiResults {
83+ names = append (names , fullAPIName (a ))
84+ }
85+ return fmt .Errorf ("ambiguous kind %q. use one of these as the KIND disambiguate: [%s]" , kind ,
86+ strings .Join (names , ", " ))
7887 }
79- return fmt .Errorf ("ambiguous kind %q. use one of these as the KIND disambiguate: [%s]" , kind ,
80- strings .Join (names , ", " ))
88+ api = apiResults [0 ]
8189 }
8290
8391 ns := * cf .Namespace
8492 if ns == "" {
8593 ns = "default" // TODO(ahmetb): how to get current-namespace from kubeconfig?
8694 }
87- obj , err := dyn .Resource (apiRes [ 0 ] .GroupVersionResource ()).Namespace (ns ).Get (name , metav1.GetOptions {})
95+ obj , err := dyn .Resource (api .GroupVersionResource ()).Namespace (ns ).Get (name , metav1.GetOptions {})
8896 if err != nil {
8997 return fmt .Errorf ("failed to get %s/%s: %w" , kind , name , err )
9098 }
@@ -100,7 +108,7 @@ func run(_ *cobra.Command, args []string) error {
100108
101109 objs := newObjectDirectory (apiObjects )
102110 if len (objs .ownership [obj .GetUID ()]) == 0 {
103- fmt .Println ("No resources are owned by the specified object through ownerReferences." )
111+ fmt .Println ("No resources are owned by this object through ownerReferences." )
104112 return nil
105113 }
106114 treeView (os .Stderr , objs , * obj )
0 commit comments