Skip to content

Commit

Permalink
Support cluster-scoped resource (#27)
Browse files Browse the repository at this point in the history
Co-authored-by: Tatsuhiro Tsujikawa <404610+tatsuhiro-t@users.noreply.github.com>
  • Loading branch information
2 people authored and ahmetb committed Jan 22, 2020
1 parent 9797034 commit eda26eb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/kubectl-tree/rootcmd.go
Expand Up @@ -115,7 +115,13 @@ func run(command *cobra.Command, args []string) error {
ns := getNamespace()
klog.V(2).Infof("namespace=%s allNamespaces=%v", ns, allNs)

obj, err := dyn.Resource(api.GroupVersionResource()).Namespace(ns).Get(name, metav1.GetOptions{})
var ri dynamic.ResourceInterface
if api.r.Namespaced {
ri = dyn.Resource(api.GroupVersionResource()).Namespace(ns)
} else {
ri = dyn.Resource(api.GroupVersionResource())
}
obj, err := ri.Get(name, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("failed to get %s/%s: %w", kind, name, err)
}
Expand Down

0 comments on commit eda26eb

Please sign in to comment.