From 2a7ef78ffc69a89e2e5189908521722f5fa9fb61 Mon Sep 17 00:00:00 2001 From: Cezar Craciunoiu Date: Thu, 8 Aug 2024 11:29:09 +0300 Subject: [PATCH 1/3] refactor(cloud)!: Use 'image' as default vs. 'img' Signed-off-by: Cezar Craciunoiu --- internal/cli/kraft/cloud/cloud.go | 6 +++--- .../kraft/cloud/{img/img.go => image/image.go} | 18 +++++++++--------- .../kraft/cloud/{img => image}/list/list.go | 2 +- .../cloud/{img => image}/remove/remove.go | 2 +- internal/cli/kraft/kraft.go | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) rename internal/cli/kraft/cloud/{img/img.go => image/image.go} (68%) rename internal/cli/kraft/cloud/{img => image}/list/list.go (99%) rename internal/cli/kraft/cloud/{img => image}/remove/remove.go (98%) diff --git a/internal/cli/kraft/cloud/cloud.go b/internal/cli/kraft/cloud/cloud.go index 24c70d49f..3e49e3393 100644 --- a/internal/cli/kraft/cloud/cloud.go +++ b/internal/cli/kraft/cloud/cloud.go @@ -15,7 +15,7 @@ import ( "kraftkit.sh/internal/cli/kraft/cloud/certificate" "kraftkit.sh/internal/cli/kraft/cloud/compose" "kraftkit.sh/internal/cli/kraft/cloud/deploy" - "kraftkit.sh/internal/cli/kraft/cloud/img" + "kraftkit.sh/internal/cli/kraft/cloud/image" "kraftkit.sh/internal/cli/kraft/cloud/instance" "kraftkit.sh/internal/cli/kraft/cloud/metros" "kraftkit.sh/internal/cli/kraft/cloud/quotas" @@ -89,8 +89,8 @@ func NewCmd() *cobra.Command { cmd.AddCommand(quotas.NewCmd()) cmd.AddCommand(tunnel.NewCmd()) - cmd.AddGroup(&cobra.Group{ID: "kraftcloud-img", Title: "IMAGE COMMANDS"}) - cmd.AddCommand(img.NewCmd()) + cmd.AddGroup(&cobra.Group{ID: "kraftcloud-image", Title: "IMAGE COMMANDS"}) + cmd.AddCommand(image.NewCmd()) cmd.AddGroup(&cobra.Group{ID: "kraftcloud-instance", Title: "INSTANCE COMMANDS"}) cmd.AddCommand(instance.NewCmd()) diff --git a/internal/cli/kraft/cloud/img/img.go b/internal/cli/kraft/cloud/image/image.go similarity index 68% rename from internal/cli/kraft/cloud/img/img.go rename to internal/cli/kraft/cloud/image/image.go index 3a539a0c3..436897731 100644 --- a/internal/cli/kraft/cloud/img/img.go +++ b/internal/cli/kraft/cloud/image/image.go @@ -3,7 +3,7 @@ // Licensed under the BSD-3-Clause License (the "License"). // You may not use this file except in compliance with the License. -package img +package image import ( "context" @@ -12,19 +12,19 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" - "kraftkit.sh/internal/cli/kraft/cloud/img/list" - "kraftkit.sh/internal/cli/kraft/cloud/img/remove" + "kraftkit.sh/internal/cli/kraft/cloud/image/list" + "kraftkit.sh/internal/cli/kraft/cloud/image/remove" "kraftkit.sh/cmdfactory" ) -type ImgOptions struct{} +type ImageOptions struct{} func NewCmd() *cobra.Command { - cmd, err := cmdfactory.New(&ImgOptions{}, cobra.Command{ + cmd, err := cmdfactory.New(&ImageOptions{}, cobra.Command{ Short: "Manage images", - Use: "img SUBCOMMAND", - Aliases: []string{"image"}, + Use: "image SUBCOMMAND", + Aliases: []string{"img, images"}, Example: heredoc.Doc(` # List images in your account. $ kraft cloud image list @@ -33,7 +33,7 @@ func NewCmd() *cobra.Command { $ kraft cloud image remove caddy@sha256:2ba5324141... `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-img", + cmdfactory.AnnotationHelpGroup: "kraftcloud-image", cmdfactory.AnnotationHelpHidden: "true", }, }) @@ -47,6 +47,6 @@ func NewCmd() *cobra.Command { return cmd } -func (opts *ImgOptions) Run(_ context.Context, _ []string) error { +func (opts *ImageOptions) Run(_ context.Context, _ []string) error { return pflag.ErrHelp } diff --git a/internal/cli/kraft/cloud/img/list/list.go b/internal/cli/kraft/cloud/image/list/list.go similarity index 99% rename from internal/cli/kraft/cloud/img/list/list.go rename to internal/cli/kraft/cloud/image/list/list.go index d08c09a7b..7128b7399 100644 --- a/internal/cli/kraft/cloud/img/list/list.go +++ b/internal/cli/kraft/cloud/image/list/list.go @@ -54,7 +54,7 @@ func NewCmd() *cobra.Command { $ kraft cloud image list -o json `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-img", + cmdfactory.AnnotationHelpGroup: "kraftcloud-image", }, }) if err != nil { diff --git a/internal/cli/kraft/cloud/img/remove/remove.go b/internal/cli/kraft/cloud/image/remove/remove.go similarity index 98% rename from internal/cli/kraft/cloud/img/remove/remove.go rename to internal/cli/kraft/cloud/image/remove/remove.go index 9439c1f92..884bda13b 100644 --- a/internal/cli/kraft/cloud/img/remove/remove.go +++ b/internal/cli/kraft/cloud/image/remove/remove.go @@ -59,7 +59,7 @@ func NewCmd() *cobra.Command { $ kraft cloud image remove --all `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-img", + cmdfactory.AnnotationHelpGroup: "kraftcloud-image", }, }) if err != nil { diff --git a/internal/cli/kraft/kraft.go b/internal/cli/kraft/kraft.go index 8daada511..f6cf53245 100644 --- a/internal/cli/kraft/kraft.go +++ b/internal/cli/kraft/kraft.go @@ -112,7 +112,7 @@ func NewCmd() *cobra.Command { cmd.AddGroup(&cobra.Group{ID: "kraftcloud", Title: "UNIKRAFT CLOUD COMMANDS"}) cmd.AddCommand(cloud.NewCmd()) - cmd.AddGroup(&cobra.Group{ID: "kraftcloud-img", Title: "UNIKRAFT CLOUD IMAGE COMMANDS"}) + cmd.AddGroup(&cobra.Group{ID: "kraftcloud-image", Title: "UNIKRAFT CLOUD IMAGE COMMANDS"}) cmd.AddGroup(&cobra.Group{ID: "kraftcloud-instance", Title: "UNIKRAFT CLOUD INSTANCE COMMANDS"}) cmd.AddGroup(&cobra.Group{ID: "kraftcloud-vol", Title: "UNIKRAFT CLOUD VOLUME COMMANDS"}) cmd.AddGroup(&cobra.Group{ID: "kraftcloud-svc", Title: "UNIKRAFT CLOUD SERVICE COMMANDS"}) From 637f67708d05e76fa9a091ff3a4bd79372d9b090 Mon Sep 17 00:00:00 2001 From: Cezar Craciunoiu Date: Thu, 8 Aug 2024 11:31:31 +0300 Subject: [PATCH 2/3] refactor(cloud)!: Use 'metro' as default vs. 'metros' Signed-off-by: Cezar Craciunoiu --- internal/cli/kraft/cloud/cloud.go | 4 ++-- .../cli/kraft/cloud/{metros => metro}/list/list.go | 0 .../kraft/cloud/{metros/metros.go => metro/metro.go} | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) rename internal/cli/kraft/cloud/{metros => metro}/list/list.go (100%) rename internal/cli/kraft/cloud/{metros/metros.go => metro/metro.go} (81%) diff --git a/internal/cli/kraft/cloud/cloud.go b/internal/cli/kraft/cloud/cloud.go index 3e49e3393..2ede88630 100644 --- a/internal/cli/kraft/cloud/cloud.go +++ b/internal/cli/kraft/cloud/cloud.go @@ -17,7 +17,7 @@ import ( "kraftkit.sh/internal/cli/kraft/cloud/deploy" "kraftkit.sh/internal/cli/kraft/cloud/image" "kraftkit.sh/internal/cli/kraft/cloud/instance" - "kraftkit.sh/internal/cli/kraft/cloud/metros" + "kraftkit.sh/internal/cli/kraft/cloud/metro" "kraftkit.sh/internal/cli/kraft/cloud/quotas" "kraftkit.sh/internal/cli/kraft/cloud/scale" "kraftkit.sh/internal/cli/kraft/cloud/service" @@ -108,7 +108,7 @@ func NewCmd() *cobra.Command { cmd.AddCommand(certificate.NewCmd()) cmd.AddGroup(&cobra.Group{ID: "kraftcloud-metro", Title: "METRO COMMANDS"}) - cmd.AddCommand(metros.NewCmd()) + cmd.AddCommand(metro.NewCmd()) cmd.AddGroup(&cobra.Group{ID: "kraftcloud-compose", Title: "COMPOSE COMMANDS"}) cmd.AddCommand(compose.NewCmd()) diff --git a/internal/cli/kraft/cloud/metros/list/list.go b/internal/cli/kraft/cloud/metro/list/list.go similarity index 100% rename from internal/cli/kraft/cloud/metros/list/list.go rename to internal/cli/kraft/cloud/metro/list/list.go diff --git a/internal/cli/kraft/cloud/metros/metros.go b/internal/cli/kraft/cloud/metro/metro.go similarity index 81% rename from internal/cli/kraft/cloud/metros/metros.go rename to internal/cli/kraft/cloud/metro/metro.go index 7395c49a0..a1d74a67b 100644 --- a/internal/cli/kraft/cloud/metros/metros.go +++ b/internal/cli/kraft/cloud/metro/metro.go @@ -3,7 +3,7 @@ // Licensed under the BSD-3-Clause License (the "License"). // You may not use this file except in compliance with the License. -package metros +package metro import ( "context" @@ -12,15 +12,15 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" - "kraftkit.sh/internal/cli/kraft/cloud/metros/list" + "kraftkit.sh/internal/cli/kraft/cloud/metro/list" "kraftkit.sh/cmdfactory" ) -type MetrosOptions struct{} +type MetroOptions struct{} func NewCmd() *cobra.Command { - cmd, err := cmdfactory.New(&MetrosOptions{}, cobra.Command{ + cmd, err := cmdfactory.New(&MetroOptions{}, cobra.Command{ Short: "Inspect Unikraft Cloud metros and regions", Use: "metro", Aliases: []string{"metros", "m"}, @@ -48,6 +48,6 @@ func NewCmd() *cobra.Command { return cmd } -func (opts *MetrosOptions) Run(_ context.Context, _ []string) error { +func (opts *MetroOptions) Run(_ context.Context, _ []string) error { return pflag.ErrHelp } From 3380c0ed589ab9ee2fa8e4a2b621cb16ec980c5c Mon Sep 17 00:00:00 2001 From: Cezar Craciunoiu Date: Thu, 8 Aug 2024 11:33:01 +0300 Subject: [PATCH 3/3] refactor(cloud)!: Use 'quota' as default vs. 'quotas' Signed-off-by: Cezar Craciunoiu --- internal/cli/kraft/cloud/cloud.go | 4 ++-- .../cloud/{quotas/quotas.go => quota/quota.go} | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) rename internal/cli/kraft/cloud/{quotas/quotas.go => quota/quota.go} (87%) diff --git a/internal/cli/kraft/cloud/cloud.go b/internal/cli/kraft/cloud/cloud.go index 2ede88630..73bb036c4 100644 --- a/internal/cli/kraft/cloud/cloud.go +++ b/internal/cli/kraft/cloud/cloud.go @@ -18,7 +18,7 @@ import ( "kraftkit.sh/internal/cli/kraft/cloud/image" "kraftkit.sh/internal/cli/kraft/cloud/instance" "kraftkit.sh/internal/cli/kraft/cloud/metro" - "kraftkit.sh/internal/cli/kraft/cloud/quotas" + "kraftkit.sh/internal/cli/kraft/cloud/quota" "kraftkit.sh/internal/cli/kraft/cloud/scale" "kraftkit.sh/internal/cli/kraft/cloud/service" "kraftkit.sh/internal/cli/kraft/cloud/tunnel" @@ -86,7 +86,7 @@ func NewCmd() *cobra.Command { } cmd.AddCommand(deploy.NewCmd()) - cmd.AddCommand(quotas.NewCmd()) + cmd.AddCommand(quota.NewCmd()) cmd.AddCommand(tunnel.NewCmd()) cmd.AddGroup(&cobra.Group{ID: "kraftcloud-image", Title: "IMAGE COMMANDS"}) diff --git a/internal/cli/kraft/cloud/quotas/quotas.go b/internal/cli/kraft/cloud/quota/quota.go similarity index 87% rename from internal/cli/kraft/cloud/quotas/quotas.go rename to internal/cli/kraft/cloud/quota/quota.go index b454b09c3..3f918efe4 100644 --- a/internal/cli/kraft/cloud/quotas/quotas.go +++ b/internal/cli/kraft/cloud/quota/quota.go @@ -3,7 +3,7 @@ // Licensed under the BSD-3-Clause License (the "License"). // You may not use this file except in compliance with the License. -package quotas +package quota import ( "context" @@ -21,7 +21,7 @@ import ( kraftcloud "sdk.kraft.cloud" ) -type QuotasOptions struct { +type QuotaOptions struct { Output string `local:"true" long:"output" short:"o" usage:"Set output format. Options: table,yaml,json,list" default:"list"` metro string @@ -29,11 +29,11 @@ type QuotasOptions struct { } func NewCmd() *cobra.Command { - cmd, err := cmdfactory.New(&QuotasOptions{}, cobra.Command{ + cmd, err := cmdfactory.New(&QuotaOptions{}, cobra.Command{ Short: "View your resource quota on Unikraft Cloud", - Use: "quotas", + Use: "quota", Args: cobra.NoArgs, - Aliases: []string{"q", "quota"}, + Aliases: []string{"q", "quotas"}, Annotations: map[string]string{ cmdfactory.AnnotationHelpGroup: "kraftcloud", }, @@ -52,7 +52,7 @@ func NewCmd() *cobra.Command { return cmd } -func (opts *QuotasOptions) Pre(cmd *cobra.Command, _ []string) error { +func (opts *QuotaOptions) Pre(cmd *cobra.Command, _ []string) error { err := utils.PopulateMetroToken(cmd, &opts.metro, &opts.token) if err != nil { return fmt.Errorf("could not populate metro and token: %w", err) @@ -65,7 +65,7 @@ func (opts *QuotasOptions) Pre(cmd *cobra.Command, _ []string) error { return nil } -func (opts *QuotasOptions) Run(ctx context.Context, _ []string) error { +func (opts *QuotaOptions) Run(ctx context.Context, _ []string) error { auth, err := config.GetKraftCloudAuthConfig(ctx, opts.token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err)