MCPcopy Create free account
hub / github.com/github/gh-aw / getSecretsRequirementsForWorkflows

Function getSecretsRequirementsForWorkflows

pkg/cli/workflow_secrets.go:18–55  ·  view source on GitHub ↗

getSecretsRequirementsForWorkflows collects secrets from all provided workflow files and returns a deduplicated list including system secrets

(workflowFiles []string)

Source from the content-addressed store, hash-verified

16// getSecretsRequirementsForWorkflows collects secrets from all provided workflow files
17// and returns a deduplicated list including system secrets
18func getSecretsRequirementsForWorkflows(workflowFiles []string) []SecretRequirement {
19 workflowSecretsLog.Printf("Collecting secrets from %d workflow files", len(workflowFiles))
20
21 var allRequirements []SecretRequirement
22 seenSecrets := make(map[string]struct {
23 })
24
25 // Map getRequiredSecretsForWorkflow over all workflows and union results
26 for _, workflowFile := range workflowFiles {
27 secrets := getSecretRequirementsForWorkflow(workflowFile)
28 for _, req := range secrets {
29 if !setutil.Contains(seenSecrets, req.Name) {
30 seenSecrets[req.Name] = struct {
31 }{}
32 allRequirements = append(allRequirements, req)
33 }
34 }
35 }
36
37 // Always add system secrets (deduplicated)
38 for _, sys := range constants.SystemSecrets {
39 if setutil.Contains(seenSecrets, sys.Name) {
40 continue
41 }
42 seenSecrets[sys.Name] = struct {
43 }{}
44 allRequirements = append(allRequirements, SecretRequirement{
45 Name: sys.Name,
46 WhenNeeded: sys.WhenNeeded,
47 Description: sys.Description,
48 Optional: sys.Optional,
49 IsEngineSecret: false,
50 })
51 }
52
53 workflowSecretsLog.Printf("Returning %d deduplicated secret requirements", len(allRequirements))
54 return allRequirements
55}
56
57// getSecretRequirementsForWorkflow extracts the engine from a workflow file and returns its required secrets.
58// It also extracts AuthDefinition secrets from inline engine definitions.

Callers 2

getSecretRequirementsFunction · 0.85

Calls 3

ContainsFunction · 0.92
PrintfMethod · 0.45

Tested by 1