From e1407038d37557e3100a1c1b893703653df77b01 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Fri, 1 Mar 2024 16:50:20 +0100 Subject: [PATCH] Configure cobra.NoArgs for bundle commands where applicable (#1250) ## Changes Return an error if unused arguments are passed to these commands. ## Tests n/a --- cmd/bundle/deploy.go | 1 + cmd/bundle/destroy.go | 6 +++--- cmd/bundle/run.go | 5 ++--- cmd/bundle/schema.go | 1 + cmd/bundle/summary.go | 6 +++--- cmd/bundle/validate.go | 6 +++--- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cmd/bundle/deploy.go b/cmd/bundle/deploy.go index cd3a2a36..60426eca 100644 --- a/cmd/bundle/deploy.go +++ b/cmd/bundle/deploy.go @@ -13,6 +13,7 @@ func newDeployCommand() *cobra.Command { cmd := &cobra.Command{ Use: "deploy", Short: "Deploy bundle", + Args: cobra.NoArgs, PreRunE: utils.ConfigureBundleWithVariables, } diff --git a/cmd/bundle/destroy.go b/cmd/bundle/destroy.go index 958681f0..b27161f9 100644 --- a/cmd/bundle/destroy.go +++ b/cmd/bundle/destroy.go @@ -16,9 +16,9 @@ import ( func newDestroyCommand() *cobra.Command { cmd := &cobra.Command{ - Use: "destroy", - Short: "Destroy deployed bundle resources", - + Use: "destroy", + Short: "Destroy deployed bundle resources", + Args: cobra.NoArgs, PreRunE: utils.ConfigureBundleWithVariables, } diff --git a/cmd/bundle/run.go b/cmd/bundle/run.go index 54aa6ae7..8814bee0 100644 --- a/cmd/bundle/run.go +++ b/cmd/bundle/run.go @@ -17,9 +17,8 @@ import ( func newRunCommand() *cobra.Command { cmd := &cobra.Command{ - Use: "run [flags] KEY", - Short: "Run a resource (e.g. a job or a pipeline)", - + Use: "run [flags] KEY", + Short: "Run a resource (e.g. a job or a pipeline)", Args: cobra.MaximumNArgs(1), PreRunE: utils.ConfigureBundleWithVariables, } diff --git a/cmd/bundle/schema.go b/cmd/bundle/schema.go index f516695c..eb0c1fc9 100644 --- a/cmd/bundle/schema.go +++ b/cmd/bundle/schema.go @@ -13,6 +13,7 @@ func newSchemaCommand() *cobra.Command { cmd := &cobra.Command{ Use: "schema", Short: "Generate JSON Schema for bundle configuration", + Args: cobra.NoArgs, } cmd.RunE = func(cmd *cobra.Command, args []string) error { diff --git a/cmd/bundle/summary.go b/cmd/bundle/summary.go index 44c79f5d..8b475661 100644 --- a/cmd/bundle/summary.go +++ b/cmd/bundle/summary.go @@ -18,9 +18,9 @@ import ( func newSummaryCommand() *cobra.Command { cmd := &cobra.Command{ - Use: "summary", - Short: "Describe the bundle resources and their deployment states", - + Use: "summary", + Short: "Describe the bundle resources and their deployment states", + Args: cobra.NoArgs, PreRunE: utils.ConfigureBundleWithVariables, // This command is currently intended for the Databricks VSCode extension only diff --git a/cmd/bundle/validate.go b/cmd/bundle/validate.go index f235e097..9a5bf1e9 100644 --- a/cmd/bundle/validate.go +++ b/cmd/bundle/validate.go @@ -12,9 +12,9 @@ import ( func newValidateCommand() *cobra.Command { cmd := &cobra.Command{ - Use: "validate", - Short: "Validate configuration", - + Use: "validate", + Short: "Validate configuration", + Args: cobra.NoArgs, PreRunE: utils.ConfigureBundleWithVariables, }