returns the list of environment names, and whether any of them were the default
(operatorEndpoint string)
| 572 | |
| 573 | // returns the list of environment names, and whether any of them were the default |
| 574 | func getEnvNamesByOperatorEndpoint(operatorEndpoint string) ([]string, bool, error) { |
| 575 | cliConfig, err := readCLIConfig() |
| 576 | if err != nil { |
| 577 | return nil, false, err |
| 578 | } |
| 579 | |
| 580 | var envNames []string |
| 581 | isDefaultEnv := false |
| 582 | |
| 583 | for _, env := range cliConfig.Environments { |
| 584 | if env.OperatorEndpoint != "" && s.LastSplit(env.OperatorEndpoint, "//") == s.LastSplit(operatorEndpoint, "//") { |
| 585 | envNames = append(envNames, env.Name) |
| 586 | if cliConfig.DefaultEnvironment != nil && env.Name == *cliConfig.DefaultEnvironment { |
| 587 | isDefaultEnv = true |
| 588 | } |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | return envNames, isDefaultEnv, nil |
| 593 | } |
| 594 | |
| 595 | func readCLIConfig() (cliconfig.CLIConfig, error) { |
| 596 | if !files.IsFile(_cliConfigPath) { |
no test coverage detected