Skip to content
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

BUG: fix incorrect config override #2086 #2087

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/_nebari/stages/infrastructure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def check_provider(cls, values):
# TODO: all cloud providers has required fields, but local and existing don't.
# And there is no way to initialize a model without user input here.
# We preserve the original behavior here, but we should find a better way to do this.
if provider in ["local", "existing"]:
if provider in ["local", "existing"] and provider not in values:
values[provider] = provider_enum_model_map[provider]()
else:
# if the provider field is invalid, it won't be set when this validator is called
Expand Down
14 changes: 14 additions & 0 deletions tests/tests_unit/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,17 @@ def test_multiple_providers(config_schema):
msg = r"Multiple providers set: \['local', 'existing'\]"
with pytest.raises(ValidationError, match=msg):
config_schema(**config_dict)


@pytest.mark.parametrize("provider", ["local", "existing"])
def test_setted_provider(config_schema, provider):
config_dict = {
"project_name": "test",
"provider": provider,
f"{provider}": {"kube_context": "some_context"},
}
config = config_schema(**config_dict)
assert config.provider == provider
result_config_dict = config.dict()
assert provider in result_config_dict
assert result_config_dict[provider]["kube_context"] == "some_context"
Loading