Remove hardcodeded kubezero output template, add support for embedded custom output formats

This commit is contained in:
Stefan Reimer 2021-02-22 19:38:44 +01:00
parent 07f8186461
commit 21cb87e9ef
6 changed files with 21 additions and 38 deletions

View File

@ -1,5 +1,9 @@
# Changelog
## 0.9.8
- Remove support for FortyTwo legacy mode as AWS now behaves as it should
- Add support for embedded custom output yaml format and removed hardcoded kubezero output template
## 0.9.7
- CloudBender now requires Python >= 3.7
- drop oyaml requirement

View File

@ -21,4 +21,4 @@ test_upload: $(PACKAGE_FILE)
twine upload --repository-url https://test.pypi.org/legacy/ dist/cloudbender-*.whl
upload: $(PACKAGE_FILE)
twine upload dist/cloudbender-*.whl
twine upload --repository-url https://upload.pypi.org/legacy/ dist/cloudbender-*.whl

View File

@ -2,7 +2,7 @@ import logging
__author__ = "Stefan Reimer"
__email__ = "stefan@zero-downtimet.net"
__version__ = "0.9.7"
__version__ = "0.9.8"
# Set up logging to ``/dev/null`` like a library is supposed to.

View File

@ -45,9 +45,3 @@ def cmd(stack, arguments):
logger.info(hook.stdout.decode("utf-8"))
except TypeError:
raise InvalidHook('Invalid argument {}'.format(arguments))
def export_outputs_kubezero(stack, arguments):
""" Write outputs in yaml for kubezero helm chart """
stack.write_outputs_file(template='kubezero.yaml', filename='kubezero.yaml')

View File

@ -357,6 +357,7 @@ class Stack(object):
def get_outputs(self, include='.*', values=False):
""" gets outputs of the stack """
self.read_template_file()
try:
stacks = self.connection_manager.call(
"cloudformation",
@ -378,24 +379,23 @@ class Stack(object):
if self.outputs:
logger.info('{} {} Outputs:\n{}'.format(self.region, self.stackname, pprint.pformat(self.outputs, indent=2)))
if self.store_outputs:
self.write_outputs_file()
try:
filename = self.cfn_data['Metadata']['CustomOutputs']['Name']
my_template = self.cfn_data['Metadata']['CustomOutputs']['Template']
except (TypeError, KeyError):
filename = self.stackname + ".yaml"
my_template = pkg_resources.read_text(templates, 'outputs.yaml')
def write_outputs_file(self, template='outputs.yaml', filename=False):
if not filename:
output_file = os.path.join(self.ctx['outputs_path'], self.rel_path, self.stackname + ".yaml")
else:
output_file = os.path.join(self.ctx['outputs_path'], self.rel_path, filename)
output_file = os.path.join(self.ctx['outputs_path'], self.rel_path, filename)
ensure_dir(os.path.join(self.ctx['outputs_path'], self.rel_path))
ensure_dir(os.path.join(self.ctx['outputs_path'], self.rel_path))
jenv = JinjaEnv()
template = jenv.from_string(my_template)
data = {'stackname': "/".join([self.rel_path, self.stackname]), 'timestamp': datetime.strftime(datetime.now(tzutc()), "%d/%m/%y %H:%M"), 'outputs': self.outputs, 'parameters': self.parameters}
my_template = pkg_resources.read_text(templates, template)
jenv = JinjaEnv()
template = jenv.from_string(my_template)
data = {'stackname': "/".join([self.rel_path, self.stackname]), 'timestamp': datetime.strftime(datetime.now(tzutc()), "%d/%m/%y %H:%M"), 'outputs': self.outputs, 'parameters': self.parameters}
with open(output_file, 'w') as output_contents:
output_contents.write(template.render(**data))
logger.info('Wrote outputs for %s to %s', self.stackname, output_file)
with open(output_file, 'w') as output_contents:
output_contents.write(template.render(**data))
logger.info('Wrote outputs for %s to %s', self.stackname, output_file)
def create_docs(self, template=False, graph=False):
""" Read rendered template, parse documentation fragments, eg. parameter description

View File

@ -1,15 +0,0 @@
---
# Source: CloudBender for stack {{ stackname }} at {{ timestamp }}
ClusterName: {{ parameters.ClusterName }}
Domain: {{ parameters.DnsZone }}
HighAvailableControlplane: {{ parameters.HighAvailable }}
cert-manager:
IamArn: {{ outputs.CertManagerRoleArn }}
kiam:
IamArn: {{ outputs.KiamServerRoleArn }}
aws-ebs-csi-driver:
IamArn: {{ outputs.EbsCsiDriverRoleArn }}