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

Function buildGuardrailConfig

cmd/pulumi.go:383–408  ·  view source on GitHub ↗

buildGuardrailConfig assembles a GuardrailConfig from the parsed flags, loading the baseline estimate JSON when --baseline is given.

(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

381// buildGuardrailConfig assembles a GuardrailConfig from the parsed flags,
382// loading the baseline estimate JSON when --baseline is given.
383func buildGuardrailConfig(cmd *cobra.Command) (estimate.GuardrailConfig, error) {
384 var cfg estimate.GuardrailConfig
385
386 if cmd.Flags().Changed("budget") {
387 v := pulumiEstimateBudget
388 cfg.Budget = &v
389 }
390 if cmd.Flags().Changed("max-increase") {
391 v := pulumiEstimateMaxIncrease
392 cfg.MaxIncrease = &v
393 }
394 if cmd.Flags().Changed("max-increase-pct") {
395 v := pulumiEstimateMaxIncreasePct
396 cfg.MaxIncreasePct = &v
397 }
398
399 if strings.TrimSpace(pulumiEstimateBaseline) != "" {
400 baseline, err := readBaselineMonthlyTotal(pulumiEstimateBaseline)
401 if err != nil {
402 return cfg, fmt.Errorf("reading --baseline: %w", err)
403 }
404 cfg.Baseline = &baseline
405 }
406
407 return cfg, nil
408}
409
410// readBaselineMonthlyTotal extracts totals.monthly_total from a previously saved
411// estimate JSON document (the output of `pulumi estimate -o json`).

Callers 1

runPulumiEstimateFunction · 0.85

Calls 1

readBaselineMonthlyTotalFunction · 0.85

Tested by

no test coverage detected