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

chore: Backfill args usage on recent commands #553

Merged
Merged
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
35 changes: 17 additions & 18 deletions cmd/command/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,48 +32,47 @@ func (p *Plural) apiCommands() []cli.Command {
Usage: "lists plural resources",
Subcommands: []cli.Command{
{
Name: "installations",
Usage: "lists your installations",
ArgsUsage: "",
Action: common.LatestVersion(p.handleInstallations),
Name: "installations",
Usage: "lists your installations",
Action: common.LatestVersion(p.handleInstallations),
},
{
Name: "charts",
Usage: "lists charts for a repository",
ArgsUsage: "REPO_ID",
Action: common.LatestVersion(common.RequireArgs(p.handleCharts, []string{"REPO_ID"})),
ArgsUsage: "{repository-id}",
Action: common.LatestVersion(common.RequireArgs(p.handleCharts, []string{"{repository-id}"})),
},
{
Name: "terraform",
Usage: "lists terraform modules for a repository",
ArgsUsage: "REPO_ID",
Action: common.LatestVersion(common.RequireArgs(p.handleTerraforma, []string{"REPO_ID"})),
ArgsUsage: "{repository-id}",
Action: common.LatestVersion(common.RequireArgs(p.handleTerraforma, []string{"{repository-id}"})),
},
{
Name: "versions",
Usage: "lists versions of a chart",
ArgsUsage: "CHART_ID",
Action: common.LatestVersion(common.RequireArgs(p.handleVersions, []string{"CHART_ID"})),
ArgsUsage: "{chart-id}",
Action: common.LatestVersion(common.RequireArgs(p.handleVersions, []string{"{chart-id}"})),
},
{
Name: "chartinstallations",
Aliases: []string{"ci"},
Usage: "lists chart installations for a repository",
ArgsUsage: "REPO_ID",
Action: common.LatestVersion(common.RequireArgs(p.handleChartInstallations, []string{"REPO_ID"})),
ArgsUsage: "{repository-id}",
Action: common.LatestVersion(common.RequireArgs(p.handleChartInstallations, []string{"{repository-id}"})),
},
{
Name: "terraforminstallations",
Aliases: []string{"ti"},
Usage: "lists terraform installations for a repository",
ArgsUsage: "REPO_ID",
Action: common.LatestVersion(common.RequireArgs(p.handleTerraformInstallations, []string{"REPO_ID"})),
ArgsUsage: "{repository-id}",
Action: common.LatestVersion(common.RequireArgs(p.handleTerraformInstallations, []string{"{repository-id}"})),
},
{
Name: "artifacts",
Usage: "Lists artifacts for a repository",
ArgsUsage: "REPO_ID",
Action: common.LatestVersion(common.RequireArgs(p.handleArtifacts, []string{"REPO_ID"})),
ArgsUsage: "{repository-id}",
Action: common.LatestVersion(common.RequireArgs(p.handleArtifacts, []string{"{repository-id}"})),
},
},
},
Expand All @@ -84,8 +83,8 @@ func (p *Plural) apiCommands() []cli.Command {
{
Name: "domain",
Usage: "creates a new domain for your account",
ArgsUsage: "DOMAIN",
Action: common.LatestVersion(p.handleCreateDomain),
ArgsUsage: "{domain}",
Action: common.LatestVersion(common.RequireArgs(p.handleCreateDomain, []string{"{domain}"})),
},
},
},
Expand Down
24 changes: 12 additions & 12 deletions cmd/command/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func TestListArtifacts(t *testing.T) {
`,
},
{
name: `test "api list artifacts" without REPO_ID parameter`,
name: `test "api list artifacts" without {repository-id} parameter`,
args: []string{plural.ApplicationName, "api", "list", "artifacts"},
expectedError: "Not enough arguments provided: needs REPO_ID. Try running --help to see usage.",
expectedError: "Not enough arguments provided: needs {repository-id}. Try running --help to see usage.",
artifacts: []api.Artifact{},
},
}
Expand Down Expand Up @@ -154,10 +154,10 @@ func TestGetCharts(t *testing.T) {
`,
},
{
name: `test "api list charts" without REPO_ID parameter`,
name: `test "api list charts" without {repository-id} parameter`,
args: []string{plural.ApplicationName, "api", "list", "charts"},
charts: []*api.Chart{},
expectedError: "Not enough arguments provided: needs REPO_ID. Try running --help to see usage.",
expectedError: "Not enough arguments provided: needs {repository-id}. Try running --help to see usage.",
},
}
for _, test := range tests {
Expand Down Expand Up @@ -214,10 +214,10 @@ func TestGetTerraform(t *testing.T) {
`,
},
{
name: `test "api list terraform" without REPO_ID parameter`,
name: `test "api list terraform" without {repository-id} parameter`,
args: []string{plural.ApplicationName, "api", "list", "terraform"},
terraform: []*api.Terraform{},
expectedError: "Not enough arguments provided: needs REPO_ID. Try running --help to see usage.",
expectedError: "Not enough arguments provided: needs {repository-id}. Try running --help to see usage.",
},
}
for _, test := range tests {
Expand Down Expand Up @@ -273,10 +273,10 @@ func TestGetVersons(t *testing.T) {
`,
},
{
name: `test "api list versions" without CHART_ID parameter`,
name: `test "api list versions" without {chart-id} parameter`,
args: []string{plural.ApplicationName, "api", "list", "versions"},
versions: []*api.Version{},
expectedError: "Not enough arguments provided: needs CHART_ID. Try running --help to see usage.",
expectedError: "Not enough arguments provided: needs {chart-id}. Try running --help to see usage.",
},
}
for _, test := range tests {
Expand Down Expand Up @@ -343,10 +343,10 @@ func TestGetChartInstallations(t *testing.T) {
`,
},
{
name: `test "api list chartinstallations" without REPO_ID parameter`,
name: `test "api list chartinstallations" without {repository-id} parameter`,
args: []string{plural.ApplicationName, "api", "list", "chartinstallations"},
chartInstallations: []*api.ChartInstallation{},
expectedError: "Not enough arguments provided: needs REPO_ID. Try running --help to see usage.",
expectedError: "Not enough arguments provided: needs {repository-id}. Try running --help to see usage.",
},
}
for _, test := range tests {
Expand Down Expand Up @@ -407,10 +407,10 @@ func TestGetTerraformInstallations(t *testing.T) {
`,
},
{
name: `test "api list terraforminstallations" without REPO_ID parameter`,
name: `test "api list terraforminstallations" without {repository-id} parameter`,
args: []string{plural.ApplicationName, "api", "list", "terraforminstallations"},
terraformInstallations: []*api.TerraformInstallation{},
expectedError: "Not enough arguments provided: needs REPO_ID. Try running --help to see usage.",
expectedError: "Not enough arguments provided: needs {repository-id}. Try running --help to see usage.",
},
}
for _, test := range tests {
Expand Down
9 changes: 5 additions & 4 deletions cmd/command/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/pluralsh/gqlclient"
"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/utils"
"github.com/urfave/cli"
Expand All @@ -30,7 +31,7 @@ func (p *Plural) authCommands() []cli.Command {
return []cli.Command{
{
Name: "oidc",
ArgsUsage: "PROVIDER",
ArgsUsage: "{provider}",
Usage: "logs in using an exchange from a given oidc id token",
Flags: []cli.Flag{
cli.StringFlag{
Expand All @@ -42,7 +43,7 @@ func (p *Plural) authCommands() []cli.Command {
Usage: "the plural email you want to log in as",
},
},
Action: p.handleOidcToken,
Action: common.RequireArgs(p.handleOidcToken, []string{"{provider}"}),
},
{
Name: "trust",
Expand Down Expand Up @@ -75,9 +76,9 @@ func (p *Plural) trustCommands() []cli.Command {
},
{
Name: "delete",
ArgsUsage: "ID",
ArgsUsage: "{id}",
Usage: "deletes an existing oidc trust relationship by id",
Action: p.handleDeleteTrust,
Action: common.RequireArgs(p.handleDeleteTrust, []string{"{id}"}),
},
}
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/command/bounce/bounce.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func Command(clients client.Plural) cli.Command {
Name: "bounce",
Aliases: []string{"b"},
Usage: "redeploys the charts in a workspace",
ArgsUsage: "APP",
Action: common.LatestVersion(common.InitKubeconfig(common.Owned(p.bounce))),
ArgsUsage: "{app}",
Action: common.LatestVersion(common.RequireArgs(common.InitKubeconfig(common.Owned(p.bounce)), []string{"{app}"})),
}
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/command/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ func (p *Plural) bundleCommands() []cli.Command {
{
Name: "list",
Usage: "lists bundles for a repository",
ArgsUsage: "REPO",
Action: common.LatestVersion(common.Rooted(common.RequireArgs(p.bundleList, []string{"repo"}))),
ArgsUsage: "{repo}",
Action: common.LatestVersion(common.Rooted(common.RequireArgs(p.bundleList, []string{"{repo}"}))),
},
{
Name: "install",
Usage: "installs a bundle and writes the configuration to this installation's context",
ArgsUsage: "REPO NAME",
ArgsUsage: "{repo} {bundle}",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "refresh",
Expand Down
11 changes: 3 additions & 8 deletions cmd/command/cd/cd.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,10 @@ func Commands(clients client.Plural, helmConfiguration *action.Configuration) []
},
{
Name: "eject",
Action: p.handleEject,
Action: common.RequireArgs(p.handleEject, []string{"{cluster-id}"}),
Usage: "ejects cluster scaffolds",
ArgsUsage: "<cluster-id>",
// TODO: enable once logic is finished
Hidden: true,
ArgsUsage: "{cluster-id}",
Hidden: true, // TODO: enable once logic is finished
},
}
}
Expand Down Expand Up @@ -287,10 +286,6 @@ func (p *Plural) handlePrintControlPlaneValues(c *cli.Context) error {
}

func (p *Plural) handleEject(c *cli.Context) (err error) {
if !c.Args().Present() {
return fmt.Errorf("clusterid cannot be empty")
}

if err := p.InitConsoleClient(consoleToken, consoleURL); err != nil {
return err
}
Expand Down
24 changes: 11 additions & 13 deletions cmd/command/cd/cd_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,16 @@ func (p *Plural) cdClusterCommands() []cli.Command {
},
{
Name: "describe",
Action: common.LatestVersion(common.RequireArgs(p.handleDescribeCluster, []string{"CLUSTER_ID"})),
Action: common.LatestVersion(common.RequireArgs(p.handleDescribeCluster, []string{"@{cluster-handle}"})),
Usage: "describe cluster",
ArgsUsage: "CLUSTER_ID",
Flags: []cli.Flag{
cli.StringFlag{Name: "o", Usage: "output format"},
},
ArgsUsage: "@{cluster-handle}",
Flags: []cli.Flag{cli.StringFlag{Name: "o", Usage: "output format"}},
},
{
Name: "update",
Action: common.LatestVersion(common.RequireArgs(p.handleUpdateCluster, []string{"CLUSTER_ID"})),
Action: common.LatestVersion(common.RequireArgs(p.handleUpdateCluster, []string{"@{cluster-handle}"})),
Usage: "update cluster",
ArgsUsage: "CLUSTER_ID",
ArgsUsage: "@{cluster-handle}",
Flags: []cli.Flag{
cli.StringFlag{Name: "handle", Usage: "unique human readable name used to identify this cluster"},
cli.StringFlag{Name: "kubeconf-path", Usage: "path to kubeconfig"},
Expand All @@ -65,9 +63,9 @@ func (p *Plural) cdClusterCommands() []cli.Command {
},
{
Name: "delete",
Action: common.LatestVersion(common.RequireArgs(p.handleDeleteCluster, []string{"CLUSTER_ID"})),
Action: common.LatestVersion(common.RequireArgs(p.handleDeleteCluster, []string{"@{cluster-handle}"})),
Usage: "deregisters a cluster in plural cd, and drains all services (unless --soft is specified)",
ArgsUsage: "CLUSTER_ID",
ArgsUsage: "@{cluster-handle}",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "soft",
Expand All @@ -78,15 +76,15 @@ func (p *Plural) cdClusterCommands() []cli.Command {
{
Name: "get-credentials",
Aliases: []string{"kubeconfig"},
Action: common.LatestVersion(common.RequireArgs(p.handleGetClusterCredentials, []string{"CLUSTER_ID"})),
Action: common.LatestVersion(common.RequireArgs(p.handleGetClusterCredentials, []string{"@{cluster-handle}"})),
Usage: "updates kubeconfig file with appropriate credentials to point to specified cluster",
ArgsUsage: "CLUSTER_ID",
ArgsUsage: "@{cluster-handle}",
},
{
Name: "create",
Action: common.LatestVersion(common.RequireArgs(p.handleCreateCluster, []string{"CLUSTER_NAME"})),
Action: common.LatestVersion(common.RequireArgs(p.handleCreateCluster, []string{"{cluster-name}"})),
Usage: "create cluster",
ArgsUsage: "CLUSTER_NAME",
ArgsUsage: "{cluster-name}",
Flags: []cli.Flag{
cli.StringFlag{Name: "handle", Usage: "unique human readable name used to identify this cluster"},
cli.StringFlag{Name: "version", Usage: "kubernetes cluster version", Required: true},
Expand Down
8 changes: 4 additions & 4 deletions cmd/command/cd/cd_contexts.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ func (p *Plural) cdServiceContextCommands() []cli.Command {
return []cli.Command{
{
Name: "upsert",
ArgsUsage: "NAME",
ArgsUsage: "{name}",
Flags: []cli.Flag{
cli.StringFlag{Name: "config-file", Usage: "path for json configuration file with the context blob", Required: true},
cli.StringFlag{Name: "name", Usage: "context name", Required: true},
},
Action: common.LatestVersion(common.RequireArgs(p.handleUpsertServiceContext, []string{"NAME"})),
Action: common.LatestVersion(common.RequireArgs(p.handleUpsertServiceContext, []string{"{name}"})),
Usage: "upsert service context",
},
{
Name: "get",
ArgsUsage: "NAME",
Action: common.LatestVersion(common.RequireArgs(p.handleGetServiceContext, []string{"NAME"})),
ArgsUsage: "{name}",
Action: common.LatestVersion(common.RequireArgs(p.handleGetServiceContext, []string{"name"})),
Usage: "get service context",
},
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/command/cd/cd_credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ func (p *Plural) cdCredentialsCommands() []cli.Command {
return []cli.Command{
{
Name: "create",
ArgsUsage: "PROVIDER_NAME",
Action: common.LatestVersion(common.RequireArgs(p.handleCreateProviderCredentials, []string{"PROVIDER_NAME"})),
ArgsUsage: "{provider-name}",
Action: common.LatestVersion(common.RequireArgs(p.handleCreateProviderCredentials, []string{"{provider-name}"})),
Usage: "create provider credentials",
},
{
Name: "delete",
ArgsUsage: "ID",
Action: common.LatestVersion(common.RequireArgs(p.handleDeleteProviderCredentials, []string{"ID"})),
ArgsUsage: "{id}",
Action: common.LatestVersion(common.RequireArgs(p.handleDeleteProviderCredentials, []string{"{id}"})),
Usage: "delete provider credentials",
},
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/command/cd/cd_notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func (p *Plural) cdNotificationSinkCommands() []cli.Command {
},
{
Name: "upsert",
ArgsUsage: "NAME",
Action: common.LatestVersion(common.RequireArgs(p.handleCreateNotificationSinks, []string{"NAME"})),
ArgsUsage: "{name}",
Action: common.LatestVersion(common.RequireArgs(p.handleCreateNotificationSinks, []string{"{name}"})),
Usage: "upsert notification sink",
},
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/command/cd/cd_pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ func (p *Plural) pipelineCommands() []cli.Command {
},
{
Name: "context",
Action: common.LatestVersion(common.RequireArgs(p.handlePipelineContext, []string{"PIPELINE_ID"})),
Action: common.LatestVersion(common.RequireArgs(p.handlePipelineContext, []string{"{pipeline-id}"})),
Usage: "set pipeline context",
ArgsUsage: "PIPELINE_ID",
ArgsUsage: "{pipeline-id}",
Flags: []cli.Flag{
cli.StringSliceFlag{
Name: "set",
Expand Down
4 changes: 2 additions & 2 deletions cmd/command/cd/cd_repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func (p *Plural) cdRepositoriesCommands() []cli.Command {
},
{
Name: "update",
ArgsUsage: "REPO_ID",
Action: common.LatestVersion(common.RequireArgs(p.handleUpdateCDRepository, []string{"REPO_ID"})),
ArgsUsage: "{repository-id}",
Action: common.LatestVersion(common.RequireArgs(p.handleUpdateCDRepository, []string{"{repository-id}"})),
Flags: []cli.Flag{
cli.StringFlag{Name: "url", Usage: "git repo url", Required: true},
cli.StringFlag{Name: "private-key", Usage: "git repo private key"},
Expand Down
Loading
Loading