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

Function loadPulumiStackConfig

cmd/pulumi.go:591–623  ·  view source on GitHub ↗
(dir string, project *pulumiworkspace.Project, stack string)

Source from the content-addressed store, hash-verified

589}
590
591func loadPulumiStackConfig(dir string, project *pulumiworkspace.Project, stack string) (map[string]string, error) {
592 if strings.TrimSpace(stack) == "" {
593 return nil, nil
594 }
595
596 sink := pulumidiag.DefaultSink(io.Discard, io.Discard, pulumidiag.FormatOptions{Color: colors.Never})
597 stackPath := pulumiStackPath(dir, project.StackConfigDir, stack)
598 projectStack, err := pulumiworkspace.LoadProjectStack(sink, project, stackPath)
599 if err != nil {
600 return nil, fmt.Errorf("loading Pulumi stack config %q: %w", stack, err)
601 }
602 if len(projectStack.Config) == 0 {
603 return nil, nil
604 }
605
606 configValues := make(map[string]string)
607 for key, value := range projectStack.Config {
608 if value.Secure() {
609 continue
610 }
611 raw, err := value.Value(pulumicfg.NopDecrypter)
612 if err != nil {
613 return nil, fmt.Errorf("reading Pulumi config %q: %w", key.String(), err)
614 }
615 configValues[key.String()] = raw
616 }
617
618 if len(configValues) == 0 {
619 return nil, nil
620 }
621
622 return configValues, nil
623}
624
625func pulumiStackPath(dir, stackConfigDir, stack string) string {
626 stackDir := dir

Callers 1

detectPulumiProjectFunction · 0.85

Calls 2

pulumiStackPathFunction · 0.85
StringMethod · 0.80

Tested by

no test coverage detected