Stop missing overlay templates from being fatal

Not all deployments will use overlays so a missing template should
not be fatal
This commit is contained in:
Liam Young
2018-04-17 12:00:17 +00:00
parent aa6573bece
commit ed98e8f02d
2 changed files with 7 additions and 0 deletions

View File

@@ -82,6 +82,11 @@ class TestCharmLifecycleDeploy(ut_utils.BaseTestCase):
handle = m()
handle.write.assert_called_once_with('Template contents')
def test_render_overlay_no_template(self):
self.patch_object(lc_deploy, 'get_template')
self.get_template.return_value = None
self.assertIsNone(lc_deploy.render_overlay('mybundle.yaml', '/tmp/'))
def test_render_overlays(self):
RESP = {
'local-charm-overlay.yaml': '/tmp/local-charm-overlay.yaml',

View File

@@ -107,6 +107,8 @@ def render_overlay(overlay_name, target_dir):
:rtype: str
"""
template = get_template(overlay_name)
if not template:
return
rendered_template_file = os.path.join(
target_dir,
os.path.basename(overlay_name))