From 61c4f07100c3583428b7b92946a5c4829aef52e4 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Tue, 10 Dec 2024 10:07:45 +0100 Subject: [PATCH] move stacks directly under cd category --- cmd/command/ai/{help.go => ai.go} | 0 cmd/command/auth/auth.go | 2 +- cmd/command/cd/cd.go | 1 - cmd/command/plural/plural.go | 2 + .../{cd/cd_stacks.go => stacks/stacks.go} | 50 +++++++++++++++---- cmd/command/version/version.go | 2 +- 6 files changed, 44 insertions(+), 13 deletions(-) rename cmd/command/ai/{help.go => ai.go} (100%) rename cmd/command/{cd/cd_stacks.go => stacks/stacks.go} (73%) diff --git a/cmd/command/ai/help.go b/cmd/command/ai/ai.go similarity index 100% rename from cmd/command/ai/help.go rename to cmd/command/ai/ai.go diff --git a/cmd/command/auth/auth.go b/cmd/command/auth/auth.go index 2310253d7..2edb7d939 100644 --- a/cmd/command/auth/auth.go +++ b/cmd/command/auth/auth.go @@ -22,7 +22,7 @@ func Command(clients client.Plural) cli.Command { } return cli.Command{ Name: "auth", - Usage: "Handles authentication to the plural api", + Usage: "handles authentication to the plural api", Subcommands: p.authCommands(), } } diff --git a/cmd/command/cd/cd.go b/cmd/command/cd/cd.go index 2e36a6b74..b3edbbbb4 100644 --- a/cmd/command/cd/cd.go +++ b/cmd/command/cd/cd.go @@ -74,7 +74,6 @@ func Commands(clients client.Plural, helmConfiguration *action.Configuration) [] p.cdPipelines(), p.cdNotifications(), p.cdSettings(), - p.cdStacks(), { Name: "install", Action: p.handleInstallDeploymentsOperator, diff --git a/cmd/command/plural/plural.go b/cmd/command/plural/plural.go index 9cb51170a..69962cb3d 100644 --- a/cmd/command/plural/plural.go +++ b/cmd/command/plural/plural.go @@ -12,6 +12,7 @@ import ( "github.com/pluralsh/plural-cli/cmd/command/mgmt" "github.com/pluralsh/plural-cli/cmd/command/pr" "github.com/pluralsh/plural-cli/cmd/command/profile" + "github.com/pluralsh/plural-cli/cmd/command/stacks" "github.com/pluralsh/plural-cli/cmd/command/up" "github.com/pluralsh/plural-cli/cmd/command/version" "github.com/pluralsh/plural-cli/pkg/client" @@ -109,6 +110,7 @@ func CreateNewApp(plural *Plural) *cli.App { down.Command(), mgmt.Command(plural.Plural), profile.Command(), + stacks.Command(plural.Plural), pr.Command(plural.Plural), cmdinit.Command(plural.Plural), up.Command(plural.Plural), diff --git a/cmd/command/cd/cd_stacks.go b/cmd/command/stacks/stacks.go similarity index 73% rename from cmd/command/cd/cd_stacks.go rename to cmd/command/stacks/stacks.go index 228755a33..04ad54dc2 100644 --- a/cmd/command/cd/cd_stacks.go +++ b/cmd/command/stacks/stacks.go @@ -1,28 +1,58 @@ -package cd +package stacks import ( "fmt" - "github.com/pluralsh/plural-cli/pkg/common" - "github.com/AlecAivazis/survey/v2" - "github.com/samber/lo" - "github.com/urfave/cli" - + "github.com/pluralsh/plural-cli/pkg/client" + "github.com/pluralsh/plural-cli/pkg/common" "github.com/pluralsh/plural-cli/pkg/config" "github.com/pluralsh/plural-cli/pkg/stacks" "github.com/pluralsh/plural-cli/pkg/utils/git" + "github.com/samber/lo" + "github.com/urfave/cli" ) -func (p *Plural) cdStacks() cli.Command { +func init() { + consoleToken = "" + consoleURL = "" +} + +var consoleToken string +var consoleURL string + +type Plural struct { + client.Plural +} + +func Command(clients client.Plural) cli.Command { + p := Plural{ + Plural: clients, + } return cli.Command{ Name: "stacks", - Subcommands: p.cdStacksCommands(), - Usage: "manage CD stacks", + Aliases: []string{"s"}, + Usage: "manage infrastructure stacks", + Subcommands: p.stacksCommands(), + Category: "CD", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "token", + Usage: "console token", + EnvVar: "PLURAL_CONSOLE_TOKEN", + Destination: &consoleToken, + }, + cli.StringFlag{ + Name: "url", + Usage: "console url address", + EnvVar: "PLURAL_CONSOLE_URL", + Destination: &consoleURL, + }, + }, } } -func (p *Plural) cdStacksCommands() []cli.Command { +func (p *Plural) stacksCommands() []cli.Command { return []cli.Command{ { Name: "gen-backend", diff --git a/cmd/command/version/version.go b/cmd/command/version/version.go index 852803c20..cfb00d9f2 100644 --- a/cmd/command/version/version.go +++ b/cmd/command/version/version.go @@ -9,7 +9,7 @@ func Command() cli.Command { return cli.Command{ Name: "version", Aliases: []string{"v", "vsn"}, - Usage: "Gets cli version info", + Usage: "gets plural cli version info", Action: common.VersionInfo, } }