Skip to content

Commit

Permalink
feat: by default use all for all environments, instead of nothing.
Browse files Browse the repository at this point in the history
  • Loading branch information
joshorr committed Feb 19, 2023
1 parent d8df718 commit 9cb5593
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
40 changes: 40 additions & 0 deletions tests/normal_tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,3 +626,43 @@ def test_dynamo_cacher_retrieves_new_values_after_local_cache_expires(directory:
# Removed the external dynamo cacher items from its table, and see if we get the new value now
# (as it will now consult with ssm provider which should re-lookup the value due to expire).
assert config.get('exp_test_value', ignore_local_caches=True) == 'expiringTestValue2'


@Config(providers=DEFAULT_TESTING_PROVIDERS)
def test_directory_order_followed():
s = xcon_settings.service
e = xcon_settings.environment

boto_clients.ssm.put_parameter(Name='/global/all/testv', Value="/g/a", Type="String")
assert config['testv'] == "/g/a"

boto_clients.ssm.put_parameter(Name=f'/global/{e}/testv', Value="/g/e", Type="String")
with InternalLocalProviderCache():
assert config['testv'] == "/g/e"

boto_clients.ssm.put_parameter(Name=f'/{s}/all/testv', Value="/s/a", Type="String")
with InternalLocalProviderCache():
assert config['testv'] == "/s/a"

boto_clients.ssm.put_parameter(Name=f'/{s}/{e}/testv', Value="/s/e", Type="String")
with InternalLocalProviderCache():
assert config['testv'] == "/s/e"

# Cache is still here, it only originally saw '/g/a'
assert config['testv'] == "/g/a"

InternalLocalProviderCache.grab().reset_cache()

assert config['testv'] == "/s/e"

config.directories = [
"/global/all/",
"/{service}/{environment}"
]

assert config['testv'] == "/g/a"

config.directories = Default
assert config['testv'] == "/s/e"


4 changes: 2 additions & 2 deletions xcon/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def __init__(self):

directories: Sequence[Directory] = (
Directory('/{service}/{environment}'),
Directory('/{service}'),
Directory('/{service}/all'),
Directory('/global/{environment}'),
Directory('/global'),
Directory('/global/all'),
)
"""
Default list of directories to use.
Expand Down

0 comments on commit 9cb5593

Please sign in to comment.