Skip to content

Commit 324efd1

Browse files
committed
Misc CLI improvements
1 parent d3bdb73 commit 324efd1

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

cli/cmd/env.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ var _envListCmd = &cobra.Command{
122122
}
123123

124124
if _flagOutput == flags.JSONOutputType {
125+
if len(cliConfig.Environments) == 0 {
126+
fmt.Print("[]")
127+
return
128+
}
125129
bytes, err := libjson.Marshal(cliConfig.Environments)
126130
if err != nil {
127131
exit.Error(err)
@@ -130,6 +134,11 @@ var _envListCmd = &cobra.Command{
130134
return
131135
}
132136

137+
if len(cliConfig.Environments) == 0 {
138+
fmt.Println("no environments are configured")
139+
return
140+
}
141+
133142
defaultEnv, err := getDefaultEnv()
134143
if err != nil {
135144
exit.Error(err)

cli/cmd/errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func ErrorInvalidProvider(providerStr string) error {
8787
func ErrorInvalidLegacyProvider(providerStr, cliConfigPath string) error {
8888
return errors.WithStack(&errors.Error{
8989
Kind: ErrInvalidLegacyProvider,
90-
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),
90+
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),
9191
})
9292
}
9393

cli/types/cliconfig/cli_config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,11 @@ func (cliConfig *CLIConfig) Validate() error {
4242
}
4343
}
4444

45+
// Backwards compatibility: ignore local default env
46+
defaultEnv := cliConfig.DefaultEnvironment
47+
if defaultEnv != nil && *defaultEnv == "local" && !envNames.Has(*defaultEnv) {
48+
cliConfig.DefaultEnvironment = nil
49+
}
50+
4551
return nil
4652
}

0 commit comments

Comments
 (0)