Skip to content

Commit

Permalink
Fix confusion with duplicate names (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
makkes authored Nov 27, 2023
1 parent bcdaae0 commit a074fae
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/kubectl-tree/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,16 @@ func apiNames(a metav1.APIResource, gv schema.GroupVersion) []string {
// TODO(ahmetb): sometimes SingularName is empty (e.g. Deployment), use lowercase Kind as fallback - investigate why
singularName = strings.ToLower(a.Kind)
}
names := []string{singularName}

pluralName := a.Name
if singularName != pluralName {
names = append(names, pluralName)
}

shortNames := a.ShortNames
names := append([]string{singularName, pluralName}, shortNames...)
names = append(names, shortNames...)

for _, n := range names {
fmtBare := n // e.g. deployment
fmtWithGroup := strings.Join([]string{n, gv.Group}, ".") // e.g. deployment.apps
Expand Down

0 comments on commit a074fae

Please sign in to comment.