secretRequirementsFromAuthDefinition converts an AuthDefinition into SecretRequirement entries so inline auth secrets are treated as required secrets (same as built-in engine secrets). Returns nil when auth is nil.
(auth *workflow.AuthDefinition, engineName string)
| 113 | // entries so inline auth secrets are treated as required secrets (same as built-in |
| 114 | // engine secrets). Returns nil when auth is nil. |
| 115 | func secretRequirementsFromAuthDefinition(auth *workflow.AuthDefinition, engineName string) []SecretRequirement { |
| 116 | if auth == nil { |
| 117 | return nil |
| 118 | } |
| 119 | |
| 120 | var reqs []SecretRequirement |
| 121 | |
| 122 | switch auth.Strategy { |
| 123 | case workflow.AuthStrategyOAuthClientCreds: |
| 124 | // OAuth client-credentials flow: require client-id and client-secret secrets. |
| 125 | if auth.ClientIDRef != "" { |
| 126 | reqs = append(reqs, SecretRequirement{ |
| 127 | Name: auth.ClientIDRef, |
| 128 | WhenNeeded: fmt.Sprintf("OAuth client ID for %s engine", engineName), |
| 129 | Description: "GitHub Actions secret holding the OAuth 2.0 client ID used to obtain access tokens.", |
| 130 | IsEngineSecret: true, |
| 131 | EngineName: engineName, |
| 132 | }) |
| 133 | } |
| 134 | if auth.ClientSecretRef != "" { |
| 135 | reqs = append(reqs, SecretRequirement{ |
| 136 | Name: auth.ClientSecretRef, |
| 137 | WhenNeeded: fmt.Sprintf("OAuth client secret for %s engine", engineName), |
| 138 | Description: "GitHub Actions secret holding the OAuth 2.0 client secret used to obtain access tokens.", |
| 139 | IsEngineSecret: true, |
| 140 | EngineName: engineName, |
| 141 | }) |
| 142 | } |
| 143 | default: |
| 144 | // api-key, bearer, or unset strategy: require the direct secret. |
| 145 | if auth.Secret != "" { |
| 146 | reqs = append(reqs, SecretRequirement{ |
| 147 | Name: auth.Secret, |
| 148 | WhenNeeded: fmt.Sprintf("API key or token for %s engine", engineName), |
| 149 | Description: "GitHub Actions secret holding the API key or bearer token for provider authentication.", |
| 150 | IsEngineSecret: true, |
| 151 | EngineName: engineName, |
| 152 | }) |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | return reqs |
| 157 | } |
| 158 | |
| 159 | // getMissingRequiredSecrets filters requirements to return only missing required secrets. |
| 160 | // It skips optional secrets and checks both primary and alternative secret names. |
no outgoing calls
no test coverage detected