(dir, stackConfigDir string)
| 527 | } |
| 528 | |
| 529 | func resolvePulumiStackName(dir, stackConfigDir string) string { |
| 530 | if stack := strings.TrimSpace(pulumiEstimateStack); stack != "" { |
| 531 | return stack |
| 532 | } |
| 533 | if stack := strings.TrimSpace(os.Getenv("PULUMI_STACK")); stack != "" { |
| 534 | return stack |
| 535 | } |
| 536 | |
| 537 | stackNames, err := listPulumiStackNames(dir, stackConfigDir) |
| 538 | if err != nil || len(stackNames) == 0 { |
| 539 | return "estimate" |
| 540 | } |
| 541 | if len(stackNames) == 1 { |
| 542 | return stackNames[0] |
| 543 | } |
| 544 | |
| 545 | for _, preferred := range []string{"dev", "development", "stage", "staging", "prod", "production"} { |
| 546 | for _, stackName := range stackNames { |
| 547 | if stackName == preferred { |
| 548 | return stackName |
| 549 | } |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | return stackNames[0] |
| 554 | } |
| 555 | |
| 556 | func listPulumiStackNames(dir, stackConfigDir string) ([]string, error) { |
| 557 | stackDir := dir |
no test coverage detected