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

Function detectRuntime

cmd/pulumi.go:460–485  ·  view source on GitHub ↗
(dir string)

Source from the content-addressed store, hash-verified

458}
459
460func detectRuntime(dir string) (string, string, map[string]string, error) {
461 data, err := os.ReadFile(filepath.Join(dir, "Pulumi.yaml"))
462 if err != nil {
463 return "", "", nil, fmt.Errorf("no Pulumi.yaml found in %s — is this a Pulumi project?", dir)
464 }
465 var p pulumiYAML
466 if err := yaml.Unmarshal(data, &p); err != nil {
467 return "", "", nil, fmt.Errorf("parsing Pulumi.yaml: %w", err)
468 }
469 if p.Runtime.name == "" {
470 return "", "", nil, fmt.Errorf("Pulumi.yaml has no runtime field")
471 }
472
473 // Collect template config defaults (e.g. aws:region default: us-west-2).
474 var templateDefaults map[string]string
475 if p.Template != nil && len(p.Template.Config) > 0 {
476 templateDefaults = make(map[string]string, len(p.Template.Config))
477 for key, cfg := range p.Template.Config {
478 if cfg.Default != "" {
479 templateDefaults[key] = cfg.Default
480 }
481 }
482 }
483
484 return p.Runtime.name, p.Runtime.Options.Virtualenv, templateDefaults, nil
485}
486
487func detectPulumiProject(dir string) (pulumiProjectInfo, error) {
488 runtime, venv, templateDefaults, err := detectRuntime(dir)

Callers 1

detectPulumiProjectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected