Remove hardcodeded kubezero output template, add support for embedded custom output formats
This commit is contained in:
parent
07f8186461
commit
21cb87e9ef
@ -1,5 +1,9 @@
|
|||||||
# Changelog
|
# 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
|
## 0.9.7
|
||||||
- CloudBender now requires Python >= 3.7
|
- CloudBender now requires Python >= 3.7
|
||||||
- drop oyaml requirement
|
- drop oyaml requirement
|
||||||
|
2
Makefile
2
Makefile
@ -21,4 +21,4 @@ test_upload: $(PACKAGE_FILE)
|
|||||||
twine upload --repository-url https://test.pypi.org/legacy/ dist/cloudbender-*.whl
|
twine upload --repository-url https://test.pypi.org/legacy/ dist/cloudbender-*.whl
|
||||||
|
|
||||||
upload: $(PACKAGE_FILE)
|
upload: $(PACKAGE_FILE)
|
||||||
twine upload dist/cloudbender-*.whl
|
twine upload --repository-url https://upload.pypi.org/legacy/ dist/cloudbender-*.whl
|
||||||
|
@ -2,7 +2,7 @@ import logging
|
|||||||
|
|
||||||
__author__ = "Stefan Reimer"
|
__author__ = "Stefan Reimer"
|
||||||
__email__ = "stefan@zero-downtimet.net"
|
__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.
|
# Set up logging to ``/dev/null`` like a library is supposed to.
|
||||||
|
@ -45,9 +45,3 @@ def cmd(stack, arguments):
|
|||||||
logger.info(hook.stdout.decode("utf-8"))
|
logger.info(hook.stdout.decode("utf-8"))
|
||||||
except TypeError:
|
except TypeError:
|
||||||
raise InvalidHook('Invalid argument {}'.format(arguments))
|
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')
|
|
||||||
|
@ -357,6 +357,7 @@ class Stack(object):
|
|||||||
def get_outputs(self, include='.*', values=False):
|
def get_outputs(self, include='.*', values=False):
|
||||||
""" gets outputs of the stack """
|
""" gets outputs of the stack """
|
||||||
|
|
||||||
|
self.read_template_file()
|
||||||
try:
|
try:
|
||||||
stacks = self.connection_manager.call(
|
stacks = self.connection_manager.call(
|
||||||
"cloudformation",
|
"cloudformation",
|
||||||
@ -378,24 +379,23 @@ class Stack(object):
|
|||||||
if self.outputs:
|
if self.outputs:
|
||||||
logger.info('{} {} Outputs:\n{}'.format(self.region, self.stackname, pprint.pformat(self.outputs, indent=2)))
|
logger.info('{} {} Outputs:\n{}'.format(self.region, self.stackname, pprint.pformat(self.outputs, indent=2)))
|
||||||
if self.store_outputs:
|
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):
|
output_file = os.path.join(self.ctx['outputs_path'], self.rel_path, filename)
|
||||||
if not filename:
|
ensure_dir(os.path.join(self.ctx['outputs_path'], self.rel_path))
|
||||||
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)
|
|
||||||
|
|
||||||
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)
|
with open(output_file, 'w') as output_contents:
|
||||||
jenv = JinjaEnv()
|
output_contents.write(template.render(**data))
|
||||||
template = jenv.from_string(my_template)
|
logger.info('Wrote outputs for %s to %s', self.stackname, output_file)
|
||||||
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)
|
|
||||||
|
|
||||||
def create_docs(self, template=False, graph=False):
|
def create_docs(self, template=False, graph=False):
|
||||||
""" Read rendered template, parse documentation fragments, eg. parameter description
|
""" Read rendered template, parse documentation fragments, eg. parameter description
|
||||||
|
@ -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 }}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user