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

fix: config env cannot be other than default #1769

Merged
merged 4 commits into from
Feb 11, 2020
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
5 changes: 3 additions & 2 deletions samcli/cli/cli_config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ def configuration_callback(cmd_name, option_name, config_env_name, saved_callbac
ctx.default_map = ctx.default_map or {}
cmd_name = cmd_name or ctx.info_name
param.default = None
config_env_name = value or config_env_name
# explicitly ignore values passed to --config-env, can be opened up in the future.
config_env_name = DEFAULT_ENV
config = get_ctx_defaults(cmd_name, provider, ctx, config_env_name=config_env_name)
ctx.default_map.update(config)

return saved_callback(ctx, param, value) if saved_callback else value
return saved_callback(ctx, param, config_env_name) if saved_callback else config_env_name


def get_ctx_defaults(cmd_name, provider, ctx, config_env_name):
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/cli/test_cli_config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from samcli.commands.exceptions import ConfigException
from samcli.cli.cli_config_file import TomlProvider, configuration_option, configuration_callback, get_ctx_defaults
from samcli.lib.config.samconfig import SamConfig
from samcli.lib.config.samconfig import SamConfig, DEFAULT_ENV


class MockContext:
Expand Down Expand Up @@ -58,6 +58,7 @@ class TestCliConfiguration(TestCase):
def setUp(self):
self.cmd_name = "test_cmd"
self.option_name = "test_option"
# No matter what config-env is passed in, default is chosen.
self.config_env = "test_config_env"
self.saved_callback = MagicMock()
self.provider = MagicMock()
Expand Down Expand Up @@ -85,8 +86,9 @@ def test_callback_with_valid_config_env(self):
value=self.value,
)
self.assertEqual(self.saved_callback.call_count, 1)
for arg in [self.ctx, self.param, self.value]:
for arg in [self.ctx, self.param, DEFAULT_ENV]:
self.assertIn(arg, self.saved_callback.call_args[0])
self.assertNotIn(self.value, self.saved_callback.call_args[0])

def test_configuration_option(self):
toml_provider = TomlProvider()
Expand Down