(envName string)
| 372 | } |
| 373 | |
| 374 | func ReadOrConfigureEnv(envName string) (cliconfig.Environment, error) { |
| 375 | existingEnv, err := readEnv(envName) |
| 376 | if err != nil { |
| 377 | return cliconfig.Environment{}, err |
| 378 | } |
| 379 | |
| 380 | if existingEnv != nil { |
| 381 | return *existingEnv, nil |
| 382 | } |
| 383 | |
| 384 | promptStr := fmt.Sprintf("the %s environment is not configured; do you already have a Cortex cluster running?", envName) |
| 385 | yesMsg := fmt.Sprintf("please configure the %s environment to point to your running cluster:\n", envName) |
| 386 | noMsg := "you can create a cluster by running the `cortex cluster up` command" |
| 387 | prompt.YesOrExit(promptStr, yesMsg, noMsg) |
| 388 | |
| 389 | env, err := configureEnv(envName, cliconfig.Environment{}) |
| 390 | if err != nil { |
| 391 | return cliconfig.Environment{}, err |
| 392 | } |
| 393 | |
| 394 | return env, nil |
| 395 | } |
| 396 | |
| 397 | func getEnvConfigDefaults(envName string) cliconfig.Environment { |
| 398 | defaults := cliconfig.Environment{} |
no test coverage detected