def render_k8s_resource(file_name, variables):
"""Render k8s resource files using jinga2.
Args:
file_name: A filename string for the yaml template
version: Version string will be used as the jinja version variable
tag: Image tag string will be used as a jinga imagetag variable
Returns:
Rendered resource dict
"""
with open(file_name, 'r') as deploy_file:
deploy_string = deploy_file.read()
deploy_template = jinja2.Template(deploy_string)
deploy_template.environment.undefined = jinja2.StrictUndefined
deploy_string = deploy_template.render(variables)
return yaml.load(deploy_string)
评论列表
文章目录