Skip to content
Snippets Groups Projects
Commit a541dfad authored by Jessica Yuen's avatar Jessica Yuen
Browse files

Add arg length constraint to commands

parent fa6d1a69
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
......@@ -60,6 +61,10 @@ var applyCmd = &cobra.Command{
Use: "apply [env-name] [-f <file-or-dir>]",
Short: `Apply local configuration to remote cluster`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 1 {
return fmt.Errorf("'apply' takes at most a single argument, that is the name of the environment")
}
flags := cmd.Flags()
var err error
......
......@@ -16,6 +16,7 @@
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
......@@ -38,6 +39,10 @@ var deleteCmd = &cobra.Command{
Use: "delete [env-name] [-f <file-or-dir>]",
Short: "Delete Kubernetes resources described in local config",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 1 {
return fmt.Errorf("'delete' takes at most a single argument, that is the name of the environment")
}
flags := cmd.Flags()
var err error
......
......@@ -16,6 +16,7 @@
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
......@@ -36,6 +37,10 @@ var diffCmd = &cobra.Command{
Use: "diff [env-name] [-f <file-or-dir>]",
Short: "Display differences between server and local config",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 1 {
return fmt.Errorf("'diff' takes at most a single argument, that is the name of the environment")
}
flags := cmd.Flags()
var err error
......
......@@ -370,7 +370,6 @@ func expandEnvCmdObjs(cmd *cobra.Command, envSpec *envSpec, cwd metadata.AbsPath
return nil, err
}
}
}
//
......
......@@ -16,6 +16,7 @@
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
......@@ -38,6 +39,10 @@ var showCmd = &cobra.Command{
Use: "show [<env>|-f <file-or-dir>]",
Short: "Show expanded resource definitions",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 1 {
return fmt.Errorf("'show' takes at most a single argument, that is the name of the environment")
}
flags := cmd.Flags()
var err error
......
......@@ -16,6 +16,7 @@
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
......@@ -41,6 +42,10 @@ var updateCmd = &cobra.Command{
Short: `[DEPRECATED] Update (or optionally create) Kubernetes resources on the cluster using the
local configuration. Accepts JSON, YAML, or Jsonnet.`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 1 {
return fmt.Errorf("'update' takes at most a single argument, that is the name of the environment")
}
flags := cmd.Flags()
var err error
......
......@@ -16,6 +16,7 @@
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
......@@ -33,6 +34,10 @@ var validateCmd = &cobra.Command{
Use: "validate [env-name] [-f <file-or-dir>]",
Short: "Compare generated manifest against server OpenAPI spec",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 1 {
return fmt.Errorf("'validate' takes at most a single argument, that is the name of the environment")
}
var err error
c := kubecfg.ValidateCmd{}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment