Skip to content

Commit

Permalink
Misc CLI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
deliahu committed Jan 6, 2021
1 parent d3bdb73 commit 324efd1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions cli/cmd/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ var _envListCmd = &cobra.Command{
}

if _flagOutput == flags.JSONOutputType {
if len(cliConfig.Environments) == 0 {
fmt.Print("[]")
return
}
bytes, err := libjson.Marshal(cliConfig.Environments)
if err != nil {
exit.Error(err)
Expand All @@ -130,6 +134,11 @@ var _envListCmd = &cobra.Command{
return
}

if len(cliConfig.Environments) == 0 {
fmt.Println("no environments are configured")
return
}

defaultEnv, err := getDefaultEnv()
if err != nil {
exit.Error(err)
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func ErrorInvalidProvider(providerStr string) error {
func ErrorInvalidLegacyProvider(providerStr, cliConfigPath string) error {
return errors.WithStack(&errors.Error{
Kind: ErrInvalidLegacyProvider,
Message: fmt.Sprintf("the %s provider is no longer supported on cortex v%s; remove the environment(s) which use the %s provider from %s or delete %s entirely (it will be recreated on subsequent CLI commands)", providerStr, consts.CortexVersionMinor, providerStr, cliConfigPath, cliConfigPath),
Message: fmt.Sprintf("the %s provider is no longer supported on cortex v%s; remove the environment(s) which use the %s provider from %s, or delete %s (it will be recreated on subsequent CLI commands)", providerStr, consts.CortexVersionMinor, providerStr, cliConfigPath, cliConfigPath),
})
}

Expand Down
6 changes: 6 additions & 0 deletions cli/types/cliconfig/cli_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,11 @@ func (cliConfig *CLIConfig) Validate() error {
}
}

// Backwards compatibility: ignore local default env
defaultEnv := cliConfig.DefaultEnvironment
if defaultEnv != nil && *defaultEnv == "local" && !envNames.Has(*defaultEnv) {
cliConfig.DefaultEnvironment = nil
}

return nil
}

0 comments on commit 324efd1

Please sign in to comment.