diff --git a/cli/cdsctl/config.go b/cli/cdsctl/config.go index 4698225c44..99650ebb62 100644 --- a/cli/cdsctl/config.go +++ b/cli/cdsctl/config.go @@ -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, diff --git a/cli/cdsctl/main.go b/cli/cdsctl/main.go index 2770813574..87527c2822 100644 --- a/cli/cdsctl/main.go +++ b/cli/cdsctl/main.go @@ -80,7 +80,7 @@ func rootFromSubCommands(cmds []*cobra.Command) *cobra.Command { return } - cli.ExitOnError(err, login().Help) + cli.ExitOnError(err, root.Help) } return root diff --git a/cli/cdsctl/version.go b/cli/cdsctl/version.go index f5cc1c955f..7cd310f2f7 100644 --- a/cli/cdsctl/version.go +++ b/cli/cdsctl/version.go @@ -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 {