Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyelei committed Oct 18, 2024
1 parent 5026df6 commit e31dd2b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/cmd/cluster/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,10 @@ func NewCustomOpsCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cob
println(`execute "kbcli cluster custom-ops --help" to list the supported command`)
},
}
cmd.AddCommand(buildCustomOpsCmds(o)...)
cmds := buildCustomOpsCmds(o)
if len(cmds) > 0 {
cmd.AddCommand(cmds...)
}
return cmd
}

Expand Down Expand Up @@ -1073,6 +1076,9 @@ func buildCustomOpsExamples(t unstructured.Unstructured) string {
func buildCustomOpsCmds(option *OperationsOptions) []*cobra.Command {
dynamic, _ := option.Factory.DynamicClient()
opsDefs, _ := dynamic.Resource(types.OpsDefinitionGVR()).List(context.TODO(), metav1.ListOptions{})
if opsDefs == nil {
return nil
}
var cmds []*cobra.Command
for _, t := range opsDefs.Items {
o := &CustomOperations{
Expand Down

0 comments on commit e31dd2b

Please sign in to comment.