diff --git a/app/gateway-api/src/orchestrator/gatewayOrchestrator.ts b/app/gateway-api/src/orchestrator/gatewayOrchestrator.ts index 668acf82..102e74ca 100644 --- a/app/gateway-api/src/orchestrator/gatewayOrchestrator.ts +++ b/app/gateway-api/src/orchestrator/gatewayOrchestrator.ts @@ -17,12 +17,13 @@ import { gatewayProfileCapabilities } from '@sammo-ts/common'; import { createGamePostgresConnector, createRedisConnector, - resolvePostgresConfigFromEnv, resolvePostgresPoolMax, resolveRedisConfigFromEnv, } from '@sammo-ts/infra'; import { isRecord } from '@sammo-ts/common'; +import { resolveGatewayPostgresConfigFromEnv } from '../gatewayPostgresConfig.js'; + import { buildTurboReleaseCommand, buildTurboReleaseTaskCommand, @@ -2249,10 +2250,10 @@ export class GatewayOrchestrator implements GatewayOrchestratorHandle { } private resolveProfileDatabaseUrl(profile: GatewayProfileRecord): string { - return resolvePostgresConfigFromEnv({ - env: this.processConfig.baseEnv ?? process.env, - schema: profile.profile, - }).url; + return resolveGatewayPostgresConfigFromEnv( + this.processConfig.baseEnv ?? process.env, + profile.profile + ).url; } private async clearTournamentRuntimeStateFromRedis(profileName: string): Promise { diff --git a/app/gateway-api/test/profileDeployOperation.test.ts b/app/gateway-api/test/profileDeployOperation.test.ts index 0998f2f5..67154d05 100644 --- a/app/gateway-api/test/profileDeployOperation.test.ts +++ b/app/gateway-api/test/profileDeployOperation.test.ts @@ -186,7 +186,15 @@ describe('profile DEPLOY operation', () => { frontendServeMode: 'static', frontendArtifactRoot: path.join(workspace, 'artifact-volume'), frontendReadinessOrigin: 'http://caddy', - baseEnv: { DATABASE_URL: 'postgresql://user:pass@integration.invalid/sammo' }, + baseEnv: { + GATEWAY_DATABASE_URL: + 'postgresql://user:encoded%23password@integration.invalid/sammo?schema=public', + POSTGRES_USER: 'user', + POSTGRES_PASSWORD: 'raw#password', + POSTGRES_HOST: 'integration.invalid', + POSTGRES_PORT: '5432', + POSTGRES_DB: 'sammo', + }, }, reconcileIntervalMs: 60_000, scheduleIntervalMs: 60_000, @@ -214,6 +222,9 @@ describe('profile DEPLOY operation', () => { expect(commandGroups[1]?.map((command) => command.args)).toEqual([ ['--filter', '@sammo-ts/infra', 'prisma:migrate:deploy:game'], ]); + expect(commandGroups[1]?.[0]?.env?.DATABASE_URL).toBe( + 'postgresql://user:encoded%23password@integration.invalid/sammo?schema=che' + ); expect(commandGroups.flat().some((command) => command.env?.GATEWAY_ROLE === 'profile-seed')).toBe(false); expect(patches.at(-1)).toMatchObject({ buildStatus: 'SUCCEEDED',