diff --git a/cli/cobra.go b/cli/cobra.go index 141ca109aee5..befee3630e3a 100644 --- a/cli/cobra.go +++ b/cli/cobra.go @@ -139,7 +139,7 @@ func hasInvalidPlugins(cmd *cobra.Command) bool { func operationSubCommands(cmd *cobra.Command) []*cobra.Command { cmds := []*cobra.Command{} for _, sub := range cmd.Commands() { - if isPlugin(sub) && invalidPluginReason(sub) != "" { + if isPlugin(sub) { continue } if sub.IsAvailableCommand() && !sub.HasSubCommands() { @@ -179,7 +179,10 @@ func vendorAndVersion(cmd *cobra.Command) string { func managementSubCommands(cmd *cobra.Command) []*cobra.Command { cmds := []*cobra.Command{} for _, sub := range cmd.Commands() { - if isPlugin(sub) && invalidPluginReason(sub) != "" { + if isPlugin(sub) { + if invalidPluginReason(sub) == "" { + cmds = append(cmds, sub) + } continue } if sub.IsAvailableCommand() && sub.HasSubCommands() { diff --git a/e2e/cli-plugins/help_test.go b/e2e/cli-plugins/help_test.go index 3d6299ee7fea..de9a1de01226 100644 --- a/e2e/cli-plugins/help_test.go +++ b/e2e/cli-plugins/help_test.go @@ -41,9 +41,9 @@ func TestGlobalHelp(t *testing.T) { regexp.MustCompile(`^A self-sufficient runtime for containers$`), regexp.MustCompile(`^Management Commands:$`), regexp.MustCompile(`^ container\s+Manage containers$`), + helloworldre, regexp.MustCompile(`^Commands:$`), regexp.MustCompile(`^ create\s+Create a new container$`), - helloworldre, regexp.MustCompile(`^ ps\s+List containers$`), regexp.MustCompile(`^Invalid Plugins:$`), badmetare,