Skip to content

Commit eda26eb

Browse files
ryysudtatsuhiro-t
authored andcommitted
Support cluster-scoped resource (#27)
Co-authored-by: Tatsuhiro Tsujikawa <[email protected]>
1 parent 9797034 commit eda26eb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cmd/kubectl-tree/rootcmd.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,13 @@ func run(command *cobra.Command, args []string) error {
115115
ns := getNamespace()
116116
klog.V(2).Infof("namespace=%s allNamespaces=%v", ns, allNs)
117117

118-
obj, err := dyn.Resource(api.GroupVersionResource()).Namespace(ns).Get(name, metav1.GetOptions{})
118+
var ri dynamic.ResourceInterface
119+
if api.r.Namespaced {
120+
ri = dyn.Resource(api.GroupVersionResource()).Namespace(ns)
121+
} else {
122+
ri = dyn.Resource(api.GroupVersionResource())
123+
}
124+
obj, err := ri.Get(name, metav1.GetOptions{})
119125
if err != nil {
120126
return fmt.Errorf("failed to get %s/%s: %w", kind, name, err)
121127
}

0 commit comments

Comments
 (0)