* Generate the SQL/connection environment variables for the given integrations and surface any * generation failures as validation issues. * * The integrations have already passed schema validation, but some fields (e.g. BigQuery / Spanner * `service_account`) only fail when the env vars are gen
( integrations: DatabaseIntegrationConfig[], projectRootDirectory: string )
| 95 | * @returns the successfully generated env vars (to inject into `process.env`) and any issues. |
| 96 | */ |
| 97 | function generateIntegrationEnvVars( |
| 98 | integrations: DatabaseIntegrationConfig[], |
| 99 | projectRootDirectory: string |
| 100 | ): { envVars: EnvVar[]; issues: ValidationIssue[] } { |
| 101 | const envVars: EnvVar[] = [] |
| 102 | const issues: ValidationIssue[] = [] |
| 103 | |
| 104 | for (const integration of integrations) { |
| 105 | const { envVars: generated, errors } = getEnvironmentVariablesForIntegrations([integration], { |
| 106 | projectRootDirectory, |
| 107 | }) |
| 108 | envVars.push(...generated) |
| 109 | |
| 110 | const integrationLabel = integration.name || integration.id |
| 111 | for (const err of errors) { |
| 112 | debug(`Integration env var error: ${err.message}`) |
| 113 | const context = integrationLabel ? `Integration "${integrationLabel}": ` : '' |
| 114 | issues.push({ |
| 115 | // Key the path by integration id rather than array index: `integrations` is the parsed |
| 116 | // (schema-valid) subset, so a positional index can drift from the file position used by |
| 117 | // schema/env errors when earlier entries were invalid. |
| 118 | path: `integrations[id=${integration.id}].metadata`, |
| 119 | message: `${context}${err.message}`, |
| 120 | code: errorCodeFromName(err.name), |
| 121 | }) |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | return { envVars, issues } |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Creates the lint action - checks for issues in a .deepnote file or integrations yaml file. |
no test coverage detected