Skip to content
11 changes: 9 additions & 2 deletions cli/cluster/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,19 @@ const (
func ErrorFailedToConnectOperator(originalError error, envName string, operatorURL string) error {
originalErrMsg := ""
if originalError != nil {
originalErrMsg = urls.TrimQueryParamsStr(errors.Message(originalError)) + "\n"
originalErrMsg = urls.TrimQueryParamsStr(errors.Message(originalError)) + "\n\n"
}

msg := fmt.Sprintf("%sunable to connect to your cluster in the %s environment (operator endpoint: %s)\n\n", originalErrMsg, envName, operatorURL)
msg += "if you don't have a cluster running:\n"
msg += fmt.Sprintf(" → if you'd like to create a cluster, run `cortex cluster up --env %s`\n", envName)
msg += fmt.Sprintf(" → otherwise you can ignore this message, and prevent it in the future with `cortex env delete %s`\n", envName)
msg += "\nif you have a cluster running:\n"
msg += fmt.Sprintf(" → run `cortex cluster info --env %s` to update your environment (include `--config <cluster.yaml>` if you have a cluster configuration file)\n", envName)

return errors.WithStack(&errors.Error{
Kind: ErrFailedToConnectOperator,
Message: fmt.Sprintf("%sfailed to connect to the operator in the %s environment (operator endpoint: %s); run `cortex env configure %s` if you need to update the operator endpoint, `cortex cluster info` to show your operator endpoint, or `cortex cluster up` to create a new cluster", originalErrMsg, envName, operatorURL, envName),
Message: msg,
})
}

Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ func getAPIsInAllEnvironments() (string, error) {

if len(errorEnvNames) == 1 {
out = s.EnsureBlankLineIfNotEmpty(out)
out += fmt.Sprintf("failed to fetch apis from %s environment; run `cortex get --env %s` to get the complete error message\n", s.UserStr(errorEnvNames[0]), errorEnvNames[0])
out += fmt.Sprintf("unable to detect apis from the %s environment; run `cortex get --env %s` if this is unexpected\n", errorEnvNames[0], errorEnvNames[0])
} else if len(errorEnvNames) > 1 {
out = s.EnsureBlankLineIfNotEmpty(out)
out += fmt.Sprintf("failed to fetch apis from %s environments; run `cortex get --env ENV_NAME` to get the complete error message\n", s.UserStrsAnd(errorEnvNames))
out += fmt.Sprintf("unable to detect apis from the %s environments; run `cortex get --env ENV_NAME` if this is unexpected\n", s.StrsAnd(errorEnvNames))
}

mismatchedAPIMessage, err := getLocalVersionMismatchedAPIsMessage()
Expand Down