@@ -67,24 +67,32 @@ func run(_ *cobra.Command, args []string) error {
67
67
68
68
kind , name := args [0 ], args [1 ]
69
69
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 , ", " ))
78
87
}
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 ]
81
89
}
82
90
83
91
ns := * cf .Namespace
84
92
if ns == "" {
85
93
ns = "default" // TODO(ahmetb): how to get current-namespace from kubeconfig?
86
94
}
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 {})
88
96
if err != nil {
89
97
return fmt .Errorf ("failed to get %s/%s: %w" , kind , name , err )
90
98
}
@@ -100,7 +108,7 @@ func run(_ *cobra.Command, args []string) error {
100
108
101
109
objs := newObjectDirectory (apiObjects )
102
110
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." )
104
112
return nil
105
113
}
106
114
treeView (os .Stderr , objs , * obj )
0 commit comments