Fix regression on loading existing environments - #1219
Merged
Conversation
In Azure#1202 we added a `config.json` file in the environment, which we use to persist configured values for required infrastructure parameters which are not set in `.parameters.json` files. As part of that logic, we made it so that the constructor of the environment would validate that a `config.json` file was present in the environment and if not, fail (similar to the check it already did for the .env file). This worked for new environments, since `.Save()` will always write an empty `config.json` file. But for existing environments, the read of the config.json would fail, with ErrNotExists, which would be wrapped up and returned to the caller. The caller would use the ErrNotExists to mean "the environment doesn't exist" and so it would prompt the user to see if they wanted to create it. Rework the constructor such that we return ErrNotExists when the directory for the environment doesn't exist, instead of using the existence of the `.env` file to mean anything and add some unit tests for these cases.
ellismg
requested review from
hemarina,
jongio,
vhvb1989,
wbreza and
weikanglim
as code owners
November 29, 2022 20:54
Collaborator
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsStandalone Binary
Container |
vhvb1989
approved these changes
Nov 29, 2022
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.
In #1202 we added a
config.jsonfile in the environment, which we use to persist configured values for required infrastructure parameters which are not set in.parameters.jsonfiles.As part of that logic, we made it so that the constructor of the environment would validate that a
config.jsonfile was present in the environment and if not, fail (similar to the check it already did for the .env file).This worked for new environments, since
.Save()will always write an emptyconfig.jsonfile. But for existing environments, the read of the config.json would fail, with ErrNotExists, which would be wrapped up and returned to the caller. The caller would use the ErrNotExists to mean "the environment doesn't exist" and so it would prompt the user to see if they wanted to create it.Rework the constructor such that we return ErrNotExists when the directory for the environment doesn't exist, instead of using the existence of the
.envfile to mean anything and add some unit tests for these cases.