Skip to content

Commit

Permalink
BUG: fix incorrect config override nebari-dev#2086
Browse files Browse the repository at this point in the history
  • Loading branch information
fangchenli committed Oct 24, 2023
1 parent 376ffba commit d04de10
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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"

0 comments on commit d04de10

Please sign in to comment.