From c97c2b436b90ec943b72727478d5098ab72650b3 Mon Sep 17 00:00:00 2001 From: Morgan Mccauley Date: Wed, 3 Apr 2024 08:58:15 +1300 Subject: [PATCH] feat: Allow overriding hasura host/port via environment --- runner/src/provisioner/provisioner.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/runner/src/provisioner/provisioner.ts b/runner/src/provisioner/provisioner.ts index 83d60ea4f..c76de820c 100644 --- a/runner/src/provisioner/provisioner.ts +++ b/runner/src/provisioner/provisioner.ts @@ -34,13 +34,15 @@ export interface DatabaseConnectionParameters { interface Config { cronDatabase: string - // Allow overriding the default values for testing - postgresHost?: string - postgresPort?: number + // Override the host/port values returned by Hasura during testing/local development + hasuraHostOverride?: string + hasuraPortOverride?: number } const defaultConfig: Config = { cronDatabase: process.env.CRON_DATABASE, + hasuraHostOverride: process.env.HASURA_HOST_OVERRIDE, + hasuraPortOverride: process.env.HASURA_POST_OVERRIDE ? Number(process.env.HASURA_POST_OVERRIDE) : undefined }; export default class Provisioner { @@ -108,8 +110,8 @@ export default class Provisioner { user: userDbConnectionParameters.username, password: userDbConnectionParameters.password, database: this.config.cronDatabase, - host: this.config.postgresHost ?? userDbConnectionParameters.host, - port: this.config.postgresPort ?? userDbConnectionParameters.port, + host: this.config.hasuraHostOverride ?? userDbConnectionParameters.host, + port: this.config.hasuraPortOverride ?? userDbConnectionParameters.port, }); await userCronPgClient.query(