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

Function parseUsageFlags

cmd/pulumi.go:1484–1506  ·  view source on GitHub ↗

parseUsageFlags parses --usage name=quantity flags into a map. Each entry must be in the form "resource-name=number", e.g. "my-api=5000000". Invalid entries are silently skipped.

(flags []string)

Source from the content-addressed store, hash-verified

1482// Each entry must be in the form "resource-name=number", e.g. "my-api=5000000".
1483// Invalid entries are silently skipped.
1484func parseUsageFlags(flags []string) map[string]float64 {
1485 if len(flags) == 0 {
1486 return nil
1487 }
1488 m := make(map[string]float64, len(flags))
1489 for _, kv := range flags {
1490 idx := strings.LastIndexByte(kv, '=')
1491 if idx < 1 {
1492 continue
1493 }
1494 name := strings.TrimSpace(kv[:idx])
1495 valStr := strings.TrimSpace(kv[idx+1:])
1496 if name == "" || valStr == "" {
1497 continue
1498 }
1499 var qty float64
1500 if _, err := fmt.Sscanf(valStr, "%f", &qty); err != nil || qty <= 0 {
1501 continue
1502 }
1503 m[name] = qty
1504 }
1505 return m
1506}
1507
1508// parseModelFlags parses --model flags into a map of resource name → ModelSelector.
1509// Format: [resource-name=]Model[:PurchaseOption[:Term]]

Callers 1

runPulumiEstimateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected