MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / resolvePulumiStackName

Function resolvePulumiStackName

cmd/pulumi.go:529–554  ·  view source on GitHub ↗
(dir, stackConfigDir string)

Source from the content-addressed store, hash-verified

527}
528
529func 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
556func listPulumiStackNames(dir, stackConfigDir string) ([]string, error) {
557 stackDir := dir

Callers 1

detectPulumiProjectFunction · 0.85

Calls 1

listPulumiStackNamesFunction · 0.85

Tested by

no test coverage detected