Switch to OS_ as the prefix for environment variables that can be used in overlay template rendering

This commit is contained in:
Liam Young
2018-04-16 14:13:23 +00:00
parent e22fa7bbf5
commit 7f09add0d0
3 changed files with 8 additions and 6 deletions

View File

@@ -8,19 +8,21 @@ import unit_tests.utils as ut_utils
class TestCharmLifecycleDeploy(ut_utils.BaseTestCase):
def test_is_valid_env_key(self):
self.assertTrue(lc_deploy.is_valid_env_key('AMULET_OS_VIP'))
self.assertTrue(lc_deploy.is_valid_env_key('ZAZA_TEMPLATE_VIP00'))
self.assertTrue(lc_deploy.is_valid_env_key('OS_VIP04'))
self.assertFalse(lc_deploy.is_valid_env_key('AMULET_OS_VIP'))
self.assertFalse(lc_deploy.is_valid_env_key('ZAZA_TEMPLATE_VIP00'))
self.assertFalse(lc_deploy.is_valid_env_key('PATH'))
def test_get_template_context_from_env(self):
self.patch_object(lc_deploy.os, 'environ')
self.environ.items.return_value = [
('AMULET_OS_VIP', '10.10.0.2'),
('OS_VIP04', '10.10.0.2'),
('ZAZA_TEMPLATE_VIP00', '20.3.4.5'),
('PATH', 'aa')]
self.assertEqual(
lc_deploy.get_template_context_from_env(),
{'AMULET_OS_VIP': '10.10.0.2', 'ZAZA_TEMPLATE_VIP00': '20.3.4.5'}
{'OS_VIP04': '10.10.0.2'}
)
def test_get_overlay_template_dir(self):

View File

@@ -41,8 +41,8 @@ the bundle.
In addition to the specified bundle the overlay template directory will be
searched for a corresponding template (\<bundle\_name\>.j2). If one is found
then the overlay will be rendered using environment variables matching
AMULET\* or ZAZA_TEMPLATE\* as a context. The rendered overlay will be used on
then the overlay will be rendered using environment variables starting with
OS\_ as a context. The rendered overlay will be used on
top of the specified bundle at deploy time.
To run manually:

View File

@@ -12,7 +12,7 @@ import zaza.charm_lifecycle.utils as utils
DEFAULT_OVERLAY_TEMPLATE_DIR = 'tests/bundles/overlays'
DEFAULT_OVERLAYS = ['local-charm-overlay.yaml']
VALID_ENVIRONMENT_KEY_PREFIXES = ['AMULET', 'ZAZA_TEMPLATE']
VALID_ENVIRONMENT_KEY_PREFIXES = ['OS_']
def is_valid_env_key(key):