Skip to content

Commit

Permalink
feat: Allow overriding hasura host/port via environment
Browse files Browse the repository at this point in the history
  • Loading branch information
morgsmccauley committed Apr 2, 2024
1 parent 8553864 commit c97c2b4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions runner/src/provisioner/provisioner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit c97c2b4

Please sign in to comment.