Skip to content

Commit

Permalink
fix(cdsctl): avoid potential panic (#5253)
Browse files Browse the repository at this point in the history
  • Loading branch information
yesnault authored Jun 15, 2020
1 parent 78d9ac2 commit a83e1a2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cli/cdsctl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ func loadConfig(cmd *cobra.Command) (string, *cdsclient.Config, error) {

cdsctx.Verbose = verbose

if cdsctx.Host == "" {
return "", nil, fmt.Errorf("invalid cdsctl configuration to reach a CDS API.")
}

config := &cdsclient.Config{
Host: cdsctx.Host,
SessionToken: cdsctx.Session,
Expand Down
2 changes: 1 addition & 1 deletion cli/cdsctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func rootFromSubCommands(cmds []*cobra.Command) *cobra.Command {
return
}

cli.ExitOnError(err, login().Help)
cli.ExitOnError(err, root.Help)
}

return root
Expand Down
2 changes: 1 addition & 1 deletion cli/cdsctl/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func versionRun(v cli.Values) error {
}

var versionAPI *sdk.Version
if cfg.Host != "" {
if cfg != nil && cfg.Host != "" {
var err error
versionAPI, err = client.Version()
if err != nil {
Expand Down

0 comments on commit a83e1a2

Please sign in to comment.