From 1a0412189464a00bc8cfd53de58984296885faed Mon Sep 17 00:00:00 2001 From: zhaohuiweixiao Date: Fri, 31 Mar 2023 17:47:41 +0800 Subject: [PATCH] Feat: list addon with specify registry (#5780) --- references/cli/addon.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/references/cli/addon.go b/references/cli/addon.go index 3a0965b16..494b4d36d 100644 --- a/references/cli/addon.go +++ b/references/cli/addon.go @@ -58,6 +58,7 @@ var enabledAddonColor = color.New(color.Bold, color.FgGreen) var ( forceDisable bool + addonRegistry string addonVersion string addonClusters string verboseStatus bool @@ -94,17 +95,22 @@ func NewAddonCommand(c common.Args, order string, ioStreams cmdutil.IOStreams) * // NewAddonListCommand create addon list command func NewAddonListCommand(c common.Args) *cobra.Command { - return &cobra.Command{ + cmd := &cobra.Command{ Use: "list", Aliases: []string{"ls"}, Short: "List addons", Long: "List addons in KubeVela", + Example: ` List addon by: + vela addon ls + List addons in a specific registry, useful to reveal addons with duplicated names: + vela addon ls --registry +`, RunE: func(cmd *cobra.Command, args []string) error { k8sClient, err := c.GetClient() if err != nil { return err } - table, err := listAddons(context.Background(), k8sClient, "") + table, err := listAddons(context.Background(), k8sClient, addonRegistry) if err != nil { return err } @@ -112,6 +118,8 @@ func NewAddonListCommand(c common.Args) *cobra.Command { return nil }, } + cmd.Flags().StringVarP(&addonRegistry, "registry", "r", "", "specify the registry name to list") + return cmd } // NewAddonEnableCommand create addon enable command