* All template vars are already FQSNs, here we just resolve them to either locations or values
( rawContent: string, platformClient: PlatformClient, alwaysUseProxy: boolean = false, )
| 171 | * All template vars are already FQSNs, here we just resolve them to either locations or values |
| 172 | */ |
| 173 | async function extractRenderedSecretsMap( |
| 174 | rawContent: string, |
| 175 | platformClient: PlatformClient, |
| 176 | alwaysUseProxy: boolean = false, |
| 177 | ): Promise<Record<string, string>> { |
| 178 | // Get all template variables |
| 179 | const templateVars = getTemplateVariables(rawContent); |
| 180 | const secrets = templateVars |
| 181 | .filter((v) => v.startsWith("secrets.")) |
| 182 | .map((v) => v.replace("secrets.", "")); |
| 183 | |
| 184 | const fqsns: FQSN[] = secrets.map(decodeFQSN); |
| 185 | |
| 186 | // FQSN -> SecretResult |
| 187 | const secretResults = await platformClient.resolveFQSNs(fqsns); |
| 188 | |
| 189 | const map: Record<string, string> = {}; |
| 190 | for (const secretResult of secretResults) { |
| 191 | if (!secretResult) { |
| 192 | continue; |
| 193 | } |
| 194 | |
| 195 | // User secrets are rendered |
| 196 | if ("value" in secretResult && !alwaysUseProxy) { |
| 197 | map[encodeFQSN(secretResult.fqsn)] = secretResult.value; |
| 198 | } else { |
| 199 | // Other secrets are rendered as secret locations and then converted to proxy types later |
| 200 | map[encodeFQSN(secretResult.fqsn)] = |
| 201 | `\${{ secrets.${encodeSecretLocation(secretResult.secretLocation)} }}`; |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | return map; |
| 206 | } |
| 207 | |
| 208 | export interface BaseUnrollAssistantOptions { |
| 209 | renderSecrets: boolean; |
no test coverage detected