Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(cloud)!: Use full name for default subcommand name #1834

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions internal/cli/kraft/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ 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"
"kraftkit.sh/internal/cli/kraft/cloud/metro"
"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"
Expand Down Expand Up @@ -86,11 +86,11 @@ 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-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())
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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",
},
})
Expand All @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"},
Expand Down Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -21,19 +21,19 @@ 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
token string
}

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",
},
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/kraft/kraft.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
Expand Down
Loading