From 7f09add0d0252a1ea230b51d5d092c0ec87c3036 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Mon, 16 Apr 2018 14:13:23 +0000 Subject: [PATCH] Switch to OS_ as the prefix for environment variables that can be used in overlay template rendering --- unit_tests/test_zaza_charm_lifecycle_deploy.py | 8 +++++--- zaza/charm_lifecycle/README.md | 4 ++-- zaza/charm_lifecycle/deploy.py | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/unit_tests/test_zaza_charm_lifecycle_deploy.py b/unit_tests/test_zaza_charm_lifecycle_deploy.py index c688cbd..61688c2 100644 --- a/unit_tests/test_zaza_charm_lifecycle_deploy.py +++ b/unit_tests/test_zaza_charm_lifecycle_deploy.py @@ -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): diff --git a/zaza/charm_lifecycle/README.md b/zaza/charm_lifecycle/README.md index 006dc4b..1f02c8c 100644 --- a/zaza/charm_lifecycle/README.md +++ b/zaza/charm_lifecycle/README.md @@ -41,8 +41,8 @@ the bundle. In addition to the specified bundle the overlay template directory will be searched for a corresponding template (\.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: diff --git a/zaza/charm_lifecycle/deploy.py b/zaza/charm_lifecycle/deploy.py index 31a45e7..547cf70 100755 --- a/zaza/charm_lifecycle/deploy.py +++ b/zaza/charm_lifecycle/deploy.py @@ -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):