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

Function checkSecretsAvailability

pkg/cli/secrets.go:103–137  ·  view source on GitHub ↗

checkSecretsAvailability checks which secrets are available and where

(secrets []SecretInfo, useActionsSecrets bool)

Source from the content-addressed store, hash-verified

101
102// checkSecretsAvailability checks which secrets are available and where
103func checkSecretsAvailability(secrets []SecretInfo, useActionsSecrets bool) []SecretInfo {
104 for i := range secrets {
105 // First check if it's in environment variables
106 if value := os.Getenv(secrets[i].Name); value != "" {
107 secrets[i].Available = true
108 secrets[i].Source = "env"
109 secrets[i].Value = value
110 continue
111 }
112
113 // If --check-secrets flag is enabled, try to fetch from GitHub Actions
114 if useActionsSecrets {
115 exists, err := checkSecretExists(secrets[i].Name)
116 if err != nil {
117 // If we get a 403 error, skip silently (no permission to check)
118 if errorutil.IsForbiddenError(err) {
119 continue
120 }
121 }
122 if exists {
123 secrets[i].Available = true
124 secrets[i].Source = "actions"
125 // Note: We can't actually fetch the secret value from GitHub Actions
126 // The secret exists but its value is not accessible via gh CLI
127 continue
128 }
129 }
130
131 // Secret not available
132 secrets[i].Available = false
133 secrets[i].Source = ""
134 }
135
136 return secrets
137}

Callers 2

validateServerSecretsFunction · 0.85

Calls 3

IsForbiddenErrorFunction · 0.92
checkSecretExistsFunction · 0.85
GetenvMethod · 0.80

Tested by 1