Skip to content

Commit

Permalink
Return error for missing arguments (#946)
Browse files Browse the repository at this point in the history
* Return error for missing arguments

* linting

* Update cmd/gitops/get/clusters/cmd.go

Co-authored-by: Simon <[email protected]>

* Change error message

* Update error message

Co-authored-by: Simon <[email protected]>
  • Loading branch information
sarataha and foot authored Oct 26, 2021
1 parent 7af3dbf commit ef7291a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cmd/gitops/get/clusters/cmd.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package clusters

import (
"fmt"
"os"

"github.com/go-resty/resty/v2"
Expand Down Expand Up @@ -49,11 +50,15 @@ func getClustersCmdRunE(endpoint *string, client *resty.Client) func(*cobra.Comm

defer w.Flush()

if len(args) == 1 {
if clustersGetCmdFlags.Kubeconfig {
return clusters.GetClusterKubeconfig(args[0], r, os.Stdout)
if clustersGetCmdFlags.Kubeconfig {
if len(args) == 0 {
return fmt.Errorf("cluster name is required")
}

return clusters.GetClusterKubeconfig(args[0], r, os.Stdout)
}

if len(args) == 1 {
return clusters.GetClusterByName(args[0], r, w)
}

Expand Down
4 changes: 4 additions & 0 deletions cmd/gitops/get/templates/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ func getTemplateCmdRunE(endpoint *string, client *resty.Client) func(*cobra.Comm
defer w.Flush()

if flags.ListTemplateParameters {
if len(args) == 0 {
return fmt.Errorf("template name is required")
}

return capi.GetTemplateParameters(args[0], r, w)
}

Expand Down

0 comments on commit ef7291a

Please sign in to comment.