-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Env vars to override DB connection #748
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fdbc59c
exclude dist folder from tsconfig
devhawk 5ce21ad
update constructPoolConfig to read override values from env
devhawk 9a3574f
deprecate debug proxy cli option
devhawk 0e69b4c
use || instead of ?? for processing env vars
devhawk 5d6f603
add test
devhawk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,23 +120,31 @@ export function constructPoolConfig(configFile: ConfigFile, cliOptions?: ParseOp | |
const databaseConnection = loadDatabaseConnection(); | ||
if (!cliOptions?.skipLoggingInParse) { | ||
const logger = new GlobalLogger(); | ||
if (configFile['database']['hostname']) { | ||
if (process.env.DBOS_DBHOST) { | ||
logger.info('Loading database connection parameters from debug environment variables'); | ||
} else if (configFile.database.hostname) { | ||
logger.info('Loading database connection parameters from dbos-config.yaml'); | ||
} else if (databaseConnection['hostname']) { | ||
} else if (databaseConnection.hostname) { | ||
logger.info('Loading database connection parameters from .dbos/db_connection'); | ||
} else { | ||
logger.info('Using default database connection parameters'); | ||
} | ||
} | ||
configFile['database']['hostname'] = | ||
configFile['database']['hostname'] || databaseConnection['hostname'] || 'localhost'; | ||
configFile['database']['port'] = configFile['database']['port'] || databaseConnection['port'] || 5432; | ||
configFile['database']['username'] = | ||
configFile['database']['username'] || databaseConnection['username'] || 'postgres'; | ||
configFile['database']['password'] = | ||
configFile['database']['password'] || databaseConnection['password'] || process.env.PGPASSWORD || 'dbos'; | ||
configFile['database']['local_suffix'] = | ||
configFile['database']['local_suffix'] || databaseConnection['local_suffix'] || false; | ||
configFile.database.hostname = | ||
process.env.DBOS_DBHOST ?? configFile.database.hostname ?? databaseConnection.hostname ?? 'localhost'; | ||
const dbos_dbport = process.env.DBOS_DBPORT ? parseInt(process.env.DBOS_DBPORT) : undefined; | ||
configFile.database.port = dbos_dbport ?? configFile.database.port ?? databaseConnection.port ?? 5432; | ||
configFile.database.username = | ||
process.env.DBOS_DBUSER ?? configFile.database.username ?? databaseConnection.username ?? 'postgres'; | ||
configFile.database.password = | ||
process.env.DBOS_DBPASSWORD ?? | ||
configFile.database.password ?? | ||
databaseConnection.password ?? | ||
process.env.PGPASSWORD ?? | ||
'dbos'; | ||
const dbos_dblocalsuffix = process.env.DBOS_DBLOCALSUFFIX ? process.env.DBOS_DBLOCALSUFFIX === 'true' : undefined; | ||
configFile.database.local_suffix = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note, using |
||
dbos_dblocalsuffix ?? configFile.database.local_suffix ?? databaseConnection.local_suffix ?? false; | ||
|
||
let databaseName: string | undefined = configFile.database.app_db_name; | ||
if (databaseName === undefined) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": ["src/**/*", "schemas/**/*"] | ||
"include": ["src/**/*", "schemas/**/*"], | ||
"exclude": ["dist/**"] | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we change to
??
(nullish coalescing) instead of||
(the OR operator)? I think the benefit of||
is that if the env variable is set to an empty string, it will consider to be not set. Otherwise, we might get some empty string variables.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, will change it back