Replace environment variable only for dab start#1641
Merged
Aniruddh25 merged 23 commits intomainfrom Aug 24, 2023
Merged
Conversation
…nfig, TryParseConfig
start
Contributor
|
|
aaronpowell
reviewed
Aug 22, 2023
abhishekkumams
approved these changes
Aug 22, 2023
aaronburtle
reviewed
Aug 23, 2023
Co-authored-by: Sean Leonard <[email protected]>
Co-authored-by: Sean Leonard <[email protected]>
aaronburtle
approved these changes
Aug 24, 2023
Contributor
aaronburtle
left a comment
There was a problem hiding this comment.
Looks good, thanks for adding this fix!
Collaborator
Author
Prefer to explicitly call replaceEnvVar=true since we dont want to accidentally leak any connectionstring if it happens by default. |
Aniruddh25
added a commit
that referenced
this pull request
Aug 24, 2023
## Why make this change? - Accidentally completed the PR #1641 before pushing the last commit that addressed review comments. I had it on my local branch, but forgot to push before merging in. This PR is to push those left over review comments into main.
Aniruddh25
added a commit
that referenced
this pull request
Aug 24, 2023
## Why make this change? - Closes #1632 - it's an unintended side effect of an optimisation pathway was added to the deserializer in #1402. Previously, deserializing the JSON config and replacing environment variables were done as two separate parses of the config JSON blob. First the JSON would be read from disk and then we'd create a JSON reader that would walk all the tokens in the file, we'd check the token to see if it matched the regex for an environment variable, we'd replace it and then return the updated JSON string. Next this would be given to the deserializer and it would be turned into the .NET object that we would use throughout the engine. This meant that we'd end up walking the AST for the JSON twice. - With #1402, when we are doing deserialization we would also do the environment variable replacement, meaning that we'd only walk the JSON AST once, thus improving performance. - There is a downside to this - the CLI doesn't need to do environment variable replacements (since we don't need to actually connect to the DB or anything, except for start, but that doesn't write out an updated config). ## What is this change? - Introduces a flag replaceEnvVar to determine whether to do the environment variable replacement in the JsonConverters when being used from the CLI commands. For `start` command this will be `true`, for all other commands this is `false`. - To minimize changes, default value of this argument was kept false. All occurrences of callers requiring this flag were modified and set to `true` in case of `start` or running the engine. - For Enums, always replace the environment variable with its value for appropriate deserialization into an Enum value. ## How was this tested? - [X] Integration Tests - Modified the End2EndTests, to test the commands `add`, `update` dont replace the environment variables, but `start` replaces it. - [X] Unit Tests - Modified the `CheckConfigEnvParsingTest` to test when replaceEnvVar is `false` we dont replace them. The `true` scenario was already being tested. Also modified the `database-type` property to be an env variable for testing enums are always replaced with values. --------- Co-authored-by: Sean Leonard <[email protected]>
Aniruddh25
added a commit
that referenced
this pull request
Aug 24, 2023
## Why make this change? - Accidentally completed the PR #1641 before pushing the last commit that addressed review comments. I had it on my local branch, but forgot to push before merging in. This PR is to push those left over review comments into main.
Aniruddh25
added a commit
that referenced
this pull request
Aug 24, 2023
## Why make this change? - Cherry-picks #1641 and #1650 to 0.8 release --------- Co-authored-by: Sean Leonard <[email protected]>
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.
Why make this change?
Previously, deserializing the JSON config and replacing environment variables were done as two separate parses of the config JSON blob. First the JSON would be read from disk and then we'd create a JSON reader that would walk all the tokens in the file, we'd check the token to see if it matched the regex for an environment variable, we'd replace it and then return the updated JSON string. Next this would be given to the deserializer and it would be turned into the .NET object that we would use throughout the engine. This meant that we'd end up walking the AST for the JSON twice.
What is this change?
startcommand this will betrue, for all other commands this isfalse.truein case ofstartor running the engine.How was this tested?
add,updatedont replace the environment variables, butstartreplaces it.CheckConfigEnvParsingTestto test when replaceEnvVar isfalsewe dont replace them. Thetruescenario was already being tested. Also modified thedatabase-typeproperty to be an env variable for testing enums are always replaced with values.