Skip to content

Commit

Permalink
Merge pull request #583 from openstack-charmers/fix-overlay-for-templ…
Browse files Browse the repository at this point in the history
…ated-bundles

Fix deploy for templated bundles
  • Loading branch information
Liam Young authored Nov 14, 2022
2 parents a7faa9a + e7b296e commit 752e021
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions unit_tests/test_zaza_charm_lifecycle_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ def test_deploy_bundle(self):
'./tests/bundles/bionic.yaml',
'newmodel',
force=True)
self.render_overlays.assert_called_once_with(
'./tests/bundles/bionic.yaml', '/tmp/mytmpdir', model_ctxt=None)
self.check_output_logging.assert_called_once_with(
['juju', 'deploy', '-m', 'newmodel', '--force',
'./tests/bundles/bionic.yaml'])
Expand Down Expand Up @@ -378,6 +380,8 @@ def test_deploy_bundle_template(self):
'./tests/bundles/bionic.yaml',
'newmodel',
force=True)
self.render_overlays.assert_called_once_with(
'/tmp/mytmpdir/bionic.yaml', '/tmp/mytmpdir', model_ctxt=None)
self.check_output_logging.assert_called_once_with(
['juju', 'deploy', '-m', 'newmodel', '--force',
'/tmp/mytmpdir/bionic.yaml'])
Expand Down
5 changes: 3 additions & 2 deletions zaza/charm_lifecycle/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ def deploy_bundle(bundle, model, model_ctxt=None, force=False, trust=False):
cmd.append('--force')
if trust:
cmd.append('--trust')
bundle_out = None
with tempfile.TemporaryDirectory() as tmpdirname:
bundle_out = '{}/{}'.format(tmpdirname, os.path.basename(bundle))
# Bundle templates should only exist in the bundle directory so
# explicitly set the Jinja2 load path.
bundle_template = get_template(
Expand All @@ -351,11 +351,12 @@ def deploy_bundle(bundle, model, model_ctxt=None, force=False, trust=False):
"Found bundle template ({}) and bundle ({})".format(
bundle_template.filename,
bundle))
bundle_out = '{}/{}'.format(tmpdirname, os.path.basename(bundle))
render_template(bundle_template, bundle_out, model_ctxt=model_ctxt)
cmd.append(bundle_out)
else:
cmd.append(bundle)
for overlay in render_overlays(bundle, tmpdirname,
for overlay in render_overlays(bundle_out or bundle, tmpdirname,
model_ctxt=model_ctxt):
logging.info("Deploying overlay '{}' on to '{}' model"
.format(overlay, model))
Expand Down

0 comments on commit 752e021

Please sign in to comment.