From 0c50a02cae13fc71aa2e63945f5e57a449fb5bab Mon Sep 17 00:00:00 2001 From: Greg Haynes Date: Tue, 21 May 2024 18:22:42 +0000 Subject: [PATCH] Move list to get clusters command, matching Kind Signed-off-by: Greg Haynes --- pkg/cmd/{list/root.go => get/clusters/clusters.go} | 14 ++++++++------ pkg/cmd/get/root.go | 2 ++ pkg/cmd/root.go | 2 -- 3 files changed, 10 insertions(+), 8 deletions(-) rename pkg/cmd/{list/root.go => get/clusters/clusters.go} (76%) diff --git a/pkg/cmd/list/root.go b/pkg/cmd/get/clusters/clusters.go similarity index 76% rename from pkg/cmd/list/root.go rename to pkg/cmd/get/clusters/clusters.go index 04f11e1c..b1f1ebd5 100644 --- a/pkg/cmd/list/root.go +++ b/pkg/cmd/get/clusters/clusters.go @@ -1,4 +1,4 @@ -package list +package clusters import ( "flag" @@ -11,9 +11,9 @@ import ( "sigs.k8s.io/kind/pkg/cluster" ) -var ListCmd = &cobra.Command{ - Use: "list", - Short: "List idp clusters", +var ClustersCmd = &cobra.Command{ + Use: "clusters", + Short: "Get idp clusters", Long: ``, RunE: list, } @@ -24,7 +24,7 @@ func init() { Development: true, } opts.BindFlags(zapfs) - ListCmd.Flags().AddGoFlagSet(zapfs) + ClustersCmd.Flags().AddGoFlagSet(zapfs) ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) } @@ -36,6 +36,8 @@ func list(cmd *cobra.Command, args []string) error { return errors.Wrapf(err, "failed to list clusters") } - fmt.Printf("Clusters: %v\n", clusters) + for _, cluster := range clusters { + fmt.Println(cluster) + } return nil } diff --git a/pkg/cmd/get/root.go b/pkg/cmd/get/root.go index 1d475878..0b24bf0e 100644 --- a/pkg/cmd/get/root.go +++ b/pkg/cmd/get/root.go @@ -3,6 +3,7 @@ package get import ( "fmt" + "github.com/cnoe-io/idpbuilder/pkg/cmd/get/clusters" "github.com/spf13/cobra" ) @@ -19,6 +20,7 @@ var ( ) func init() { + GetCmd.AddCommand(clusters.ClustersCmd) GetCmd.AddCommand(SecretsCmd) GetCmd.PersistentFlags().StringSliceVarP(&packages, "packages", "p", []string{}, "names of packages.") GetCmd.PersistentFlags().StringVarP(&outputFormat, "output", "o", "", "Output format. json or yaml.") diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index 340f16b6..ce1aca38 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -8,7 +8,6 @@ import ( "github.com/cnoe-io/idpbuilder/pkg/cmd/delete" "github.com/cnoe-io/idpbuilder/pkg/cmd/get" "github.com/cnoe-io/idpbuilder/pkg/cmd/helpers" - "github.com/cnoe-io/idpbuilder/pkg/cmd/list" "github.com/cnoe-io/idpbuilder/pkg/cmd/version" "github.com/spf13/cobra" ) @@ -24,7 +23,6 @@ func init() { rootCmd.AddCommand(create.CreateCmd) rootCmd.AddCommand(get.GetCmd) rootCmd.AddCommand(delete.DeleteCmd) - rootCmd.AddCommand(list.ListCmd) rootCmd.AddCommand(version.VersionCmd) }