Browse Source

Add deployment_data to rendered docs

A bug was found where the deployment_data document was not being
included in the upload to shipyard. Upon investigation it was also
noticed that deployment_data wasn't being rendered.

This patch updates the render and upload commands to include the
deployment data document.

Change-Id: I916132e80ac13546468f171a75517a9159e48ea6
changes/06/681606/7
Alexander Hughes 2 years ago
committed by Alexander Hughes
parent
commit
bc6554241b
  1. 3
      .gitignore
  2. 8
      pegleg/engine/site.py
  3. 3
      pegleg/engine/util/shipyard_helper.py
  4. 11
      tests/unit/engine/util/test_shipyard_helper.py

3
.gitignore

@ -114,3 +114,6 @@ AUTHORS
# Ansible
*.retry
# Linux
~

8
pegleg/engine/site.py

@ -54,7 +54,7 @@ def _collect_to_stdout(site_name):
click.echo("\n".join(line.splitlines()))
add_representer_ordered_dict()
res = yaml.safe_dump(
_get_deployment_data_doc(),
get_deployment_data_doc(),
explicit_start=True,
explicit_end=True,
default_flow_style=False)
@ -87,7 +87,7 @@ def _collect_to_file(site_name, save_location):
add_representer_ordered_dict()
save_files[curr_site_repo].writelines(
yaml.safe_dump(
_get_deployment_data_doc(),
get_deployment_data_doc(),
default_flow_style=False,
explicit_start=True,
explicit_end=True))
@ -107,7 +107,7 @@ def collect(site_name, save_location):
def render(site_name, output_stream, validate):
rendered_documents = get_rendered_docs(site_name, validate=validate)
rendered_documents.append(get_deployment_data_doc())
if output_stream:
files.dump_all(
rendered_documents,
@ -192,7 +192,7 @@ def show(site_name, output_stream):
click.echo(msg)
def _get_deployment_data_doc():
def get_deployment_data_doc():
stanzas = {
files.path_leaf(repo): _get_repo_deployment_data_stanza(repo)
for repo in config.all_repos()

3
pegleg/engine/util/shipyard_helper.py

@ -22,6 +22,7 @@ from shipyard_client.api_client.shipyardclient_context import \
import yaml
from pegleg.engine import exceptions
from pegleg.engine import site
from pegleg.engine.util import files
from pegleg.engine.util.files import add_representer_ordered_dict
from pegleg.engine.util.pegleg_secret_management import PeglegSecretManagement
@ -76,7 +77,7 @@ class ShipyardHelper(object):
collected_documents = files.collect_files_by_repo(self.site_name)
collection_data = []
collection_data = [site.get_deployment_data_doc()]
LOG.info("Processing %d collection(s)", len(collected_documents))
for idx, document in enumerate(collected_documents):
# Decrypt the documents if encrypted

11
tests/unit/engine/util/test_shipyard_helper.py

@ -20,6 +20,7 @@ import pytest
import yaml
from pegleg.engine import util
from pegleg.engine.site import get_deployment_data_doc
from pegleg.engine.util.shipyard_helper import ShipyardHelper
from pegleg.engine.util.shipyard_helper import ShipyardClient
@ -151,6 +152,10 @@ def _get_data_as_collection(data):
return yaml.dump_all(collection, Dumper=yaml.SafeDumper)
def _get_deployment_data_as_yaml():
return yaml.safe_dump(get_deployment_data_doc())
def test_shipyard_helper_init_():
""" Tests ShipyardHelper init method """
# Scenario:
@ -197,7 +202,11 @@ def test_upload_documents(*args):
# Validate Shipyard call to post configdocs was invoked with correct
# collection name and buffer mode.
expected_data = _get_data_as_collection(MULTI_REPO_DATA)
expected_data = '---\n'.join(
[
_get_deployment_data_as_yaml(),
_get_data_as_collection(MULTI_REPO_DATA)
])
mock_api_client.post_configdocs.assert_called_with(
collection_id='test-site',
buffer_mode='replace',

Loading…
Cancel
Save