Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

Allow database prepare command to use environment variables.#586

Closed
ghunteranderson wants to merge 1 commit into
pantsel:masterfrom
ghunteranderson:bugfix/allow-env-vars-during-prepare
Closed

Allow database prepare command to use environment variables.#586
ghunteranderson wants to merge 1 commit into
pantsel:masterfrom
ghunteranderson:bugfix/allow-env-vars-during-prepare

Conversation

@ghunteranderson

Copy link
Copy Markdown

The files /makedb/dbs/pg.js, makedb/dbs/mysql.js and /config/connections.js allow the user to pass the standard database connection environment variables into the prepare command so long as a connection URL is not set. However, if -u <url> is not passed into start.sh, then the kong.js invocation becomes ./bin/kong.js prepare --adapter postgres --uri. The argument parser then interprets this as argv.uri=true and the process tries to connect with connection URL "true". The changes in start.sh attempt to address this.

Moving on to kong.js, we omit setting process.env.DB_URI at all if argv.uri is empty. This prevents process.env.DB_URI from becoming string "undefined" and causing the same problem as string "true".

Finally, this PR removes the validation requiring a connection URL. I believe this is currently ignored if ran via startup.sh as argv.uri was either true or a nonempty string.

…om start.sh.

This allows environment variables to be used in prepare step rather than parsing the mistaken url "true".
@ghunteranderson

Copy link
Copy Markdown
Author

I believe this PR may address #323. All the @pantsel would need to do is add the standard environment variables DB_HOST, DB_USER, DB_PASSWORD, etc and omit the -u <url> argument.

For me, I have passwords that may not be url safe. The encodeURI function doesn't encode the password and uri.parse(str) can't correctly parse if ":", "@" and "/" are not encoded. Using the environment variables are a great alternative and were my first preference.

mloskot added a commit to Cadcorp/konga that referenced this pull request Dec 4, 2020
mloskot added a commit to Cadcorp/konga that referenced this pull request Dec 8, 2020
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant