[CherryPick]: Replace environment variable only for dab start#1652
Merged
Aniruddh25 merged 2 commits intorelease/0.8from Aug 24, 2023
Merged
[CherryPick]: Replace environment variable only for dab start#1652Aniruddh25 merged 2 commits intorelease/0.8from
start#1652Aniruddh25 merged 2 commits intorelease/0.8from
Conversation
## 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]>
## 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.
seantleonard
approved these changes
Aug 24, 2023
aaronburtle
approved these changes
Aug 24, 2023
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?
start#1641 and Addressing left over review comments from #1641 #1650 to 0.8 release