Allow accepting env vars for config#128
Open
quintenpalmer wants to merge 3 commits intorubenv:masterfrom
Open
Conversation
added 3 commits
December 14, 2018 14:32
This function reads the map of config environments to Environment structs from the dbconfig.yml file. We want to allow these commands to also read from the shell environment, so for unambiguous names this is being renamed.
This is in the same vein of the previous commit where we want to be able to parse an Environment from the shell environment, so to make that switch easier, this function now returns the Environemnt and can be substituted for another function which reads from the environment.
We want to build the ability for this command to accept the Environment through the shell env. If the file is not present, we optimistically look for the Environment in said shell env. There are existing zero-value checks to make sure that a user doesn't accidentally end up with no values for anything if their file was empty. We do a separate stat to check for the file to keep the complexity of the fallback simpler. The envconfig package can be researched more here: https://github.com/kelseyhightower/envconfig
Contributor
Author
|
@rubenv have you had a chance to take a look at this PR? Would like to get this merged to you upstream if possible, let me know if that will be the case please. |
|
@rubenv I have added env configurability to the ignore-unknown setting as well. If you are interested in env configurability, it would be great if this PR could get merged first so that I can open a PR for the ignore-unknown addition. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Our company has a use case to provide the environment information through the shell environment instead of from a
dbconfig.ymlfile. We have augmented thesql-migratebinary's capability to check for adbconfig.ymlfile before trying to read it in, and if there is no file present, it will be optimistic and try to read from the shell environment. Failing to read from the environment if there is no file will work as it did before with the zero-value checking that happens in the last part ofGetEnvironment. If these changes are acceptable to introduce to the parent project would like to do so.Example usage showing that this:
dbconfig.ymlif presentdbconfig.ymlis not present