From ea670cfaf1809fde52606e3094340dc99e2ad0ce Mon Sep 17 00:00:00 2001 From: vishal Date: Mon, 24 Aug 2020 15:13:18 -0400 Subject: [PATCH 1/2] Update get.go --- cli/cmd/get.go | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/cli/cmd/get.go b/cli/cmd/get.go index 34461c7213..10d6889634 100644 --- a/cli/cmd/get.go +++ b/cli/cmd/get.go @@ -189,13 +189,26 @@ func getAPIsInAllEnvironments() (string, error) { out := "" if len(allRealtimeAPIs) == 0 && len(allBatchAPIs) == 0 && len(allTrafficSplitters) == 0 { - if len(errorsMap) == 1 { - // Print the error if there is just one - exit.Error(errors.FirstErrorInMap(errorsMap)) - } // if all envs errored, skip "no apis are deployed" since it's misleading if len(errorsMap) != len(cliConfig.Environments) { - out += console.Bold("no apis are deployed") + "\n" + if len(errorsMap) == 0 { + return console.Bold("no apis are deployed"), nil + } + + var successfulEnvs []string + for _, env := range cliConfig.Environments { + if _, ok := errorsMap[env.Name]; !ok { + successfulEnvs = append(successfulEnvs, env.Name) + } + } + fmt.Println(console.Bold(fmt.Sprintf("no apis are deployed in %s: %s", s.PluralS("environment", len(successfulEnvs)), s.StrsAnd(successfulEnvs))) + "\n") + } + + // Print the first error + for name, err := range errorsMap { + if err != nil { + exit.Error(errors.Wrap(err, "env "+name)) + } } } else { if len(allBatchAPIs) > 0 { From 7d13486880851274605ab8ee2666baf1e904b91a Mon Sep 17 00:00:00 2001 From: vishal Date: Mon, 24 Aug 2020 16:26:28 -0400 Subject: [PATCH 2/2] Update get.go --- cli/cmd/get.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/cmd/get.go b/cli/cmd/get.go index 10d6889634..f8675d0ab1 100644 --- a/cli/cmd/get.go +++ b/cli/cmd/get.go @@ -189,7 +189,7 @@ func getAPIsInAllEnvironments() (string, error) { out := "" if len(allRealtimeAPIs) == 0 && len(allBatchAPIs) == 0 && len(allTrafficSplitters) == 0 { - // if all envs errored, skip "no apis are deployed" since it's misleading + // check if any environments errorred if len(errorsMap) != len(cliConfig.Environments) { if len(errorsMap) == 0 { return console.Bold("no apis are deployed"), nil