-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable overriding values in goth config file #489
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,44 @@ def test_parse_default_config(default_config_file: Path): | |
|
||
config = load_yaml(default_config_file) | ||
assert config.compose_config.build_env | ||
|
||
|
||
def test_load_yaml_override_existing(default_config_file: Path): | ||
"""Test overriding an existing field in a YAML config file.""" | ||
|
||
test_key = "zksync" | ||
test_value = ".*I am overridden!.*" | ||
overrides = [ | ||
(f"docker-compose.compose-log-patterns.{test_key}", test_value), | ||
] | ||
|
||
config = load_yaml(default_config_file, overrides) | ||
|
||
assert config.compose_config.log_patterns[test_key] == test_value | ||
|
||
|
||
def test_load_yaml_override_new(default_config_file: Path): | ||
"""Test adding a new field to a YAML config file through overrides.""" | ||
|
||
test_value = "v0.0.1-rc666" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤘 |
||
overrides = [ | ||
("docker-compose.build-environment.release-tag", test_value), | ||
] | ||
|
||
config = load_yaml(default_config_file, overrides) | ||
|
||
assert config.compose_config.build_env.release_tag == test_value | ||
|
||
|
||
def test_load_yaml_override_top_level(default_config_file: Path): | ||
"""Test overriding a value under a top-level dict in the YAML file.""" | ||
|
||
test_value = "overridden-name" | ||
overrides = [ | ||
("web-root", test_value), | ||
] | ||
|
||
config = load_yaml(default_config_file, overrides) | ||
|
||
assert config.web_root | ||
assert config.web_root.name == test_value |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could also allow
int
s inpath_list
and then override like this:But it's probably not worth doing, if we ever need to identify config elements based on list indices then it would be probably an indication that the relevant part of the configuration tree should be made a
dir
instead of alist
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to limit ourselves to
dict
s for now. The only use-cases I see for list access in our current config file is for debugging purposes. As such, this can be achieved by editing the file itself, rather than using overrides.With that said I'm going to mention the limitation to
dict
in the docstring forload_yaml
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 8f83b54