dummyValueForConfigKey returns a reasonable dummy value for a non-pricing config key. For keys that look like they expect a number, returns "1". For keys that look like secrets/passwords, returns a long-enough string. For keys that look like names/usernames, returns "dummy". Otherwise returns "dummy
(key string)
| 1449 | // For keys that look like names/usernames, returns "dummy". |
| 1450 | // Otherwise returns "dummy". |
| 1451 | func dummyValueForConfigKey(key string) string { |
| 1452 | lower := strings.ToLower(key) |
| 1453 | |
| 1454 | // Numeric-looking keys |
| 1455 | numericHints := []string{"size", "count", "number", "num", "port", "desired", "min", "max", "replicas", "capacity"} |
| 1456 | for _, hint := range numericHints { |
| 1457 | if strings.Contains(lower, hint) { |
| 1458 | return "1" |
| 1459 | } |
| 1460 | } |
| 1461 | |
| 1462 | // Secret/password/key-looking keys — some programs validate minimum length |
| 1463 | secretHints := []string{"password", "secret", "token", "key", "credential"} |
| 1464 | for _, hint := range secretHints { |
| 1465 | if strings.Contains(lower, hint) { |
| 1466 | return "dummySecret01234567890123456789012345678901234567890" |
| 1467 | } |
| 1468 | } |
| 1469 | |
| 1470 | // Name/username-looking keys |
| 1471 | nameHints := []string{"name", "user", "email", "admin", "owner", "account"} |
| 1472 | for _, hint := range nameHints { |
| 1473 | if strings.Contains(lower, hint) { |
| 1474 | return "dummy" |
| 1475 | } |
| 1476 | } |
| 1477 | |
| 1478 | return "dummy" |
| 1479 | } |
| 1480 | |
| 1481 | // parseUsageFlags parses --usage name=quantity flags into a map. |
| 1482 | // Each entry must be in the form "resource-name=number", e.g. "my-api=5000000". |