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

Function scanRequiredConfigKeys

cmd/pulumi.go:1298–1345  ·  view source on GitHub ↗

scanRequiredConfigKeys scans source files in the project directory for config.require(...) / config.require_secret(...) calls and returns the fully-qualified config key names (namespace:key).

(dir, projectName, runtime string)

Source from the content-addressed store, hash-verified

1296// config.require(...) / config.require_secret(...) calls and returns the
1297// fully-qualified config key names (namespace:key).
1298func scanRequiredConfigKeys(dir, projectName, runtime string) []string {
1299 // Determine which file extensions to scan based on runtime.
1300 var globs []string
1301 switch runtime {
1302 case "python":
1303 globs = []string{"*.py"}
1304 case "nodejs", "node":
1305 globs = []string{"*.ts", "*.js"}
1306 case "go":
1307 globs = []string{"*.go"}
1308 case "dotnet":
1309 globs = []string{"*.cs", "*.fs"}
1310 case "java":
1311 globs = []string{"*.java"}
1312 case "yaml":
1313 // YAML projects declare resources declaratively; no config.require() calls to scan.
1314 return nil
1315 default:
1316 globs = []string{"*.py", "*.ts", "*.js", "*.go", "*.cs", "*.java"}
1317 }
1318
1319 seen := map[string]bool{}
1320 var keys []string
1321
1322 for _, glob := range globs {
1323 matches, err := filepath.Glob(filepath.Join(dir, glob))
1324 if err != nil {
1325 continue
1326 }
1327 for _, fpath := range matches {
1328 data, err := os.ReadFile(fpath)
1329 if err != nil {
1330 continue
1331 }
1332 content := string(data)
1333 fileKeys := extractRequiredKeys(content, projectName)
1334 for _, k := range fileKeys {
1335 if !seen[k] {
1336 seen[k] = true
1337 keys = append(keys, k)
1338 }
1339 }
1340 }
1341 }
1342
1343 sort.Strings(keys)
1344 return keys
1345}
1346
1347// extractRequiredKeys parses source code content and returns fully-qualified
1348// config keys (namespace:key). It tracks which Config object uses which

Callers 1

runPulumiEstimateFunction · 0.85

Calls 1

extractRequiredKeysFunction · 0.85

Tested by

no test coverage detected