Allow any kubefile to be a jinja template

This is simpler than patching in the kustomization.yaml.jinja
This commit is contained in:
Stéphane Bidoul 2025-09-13 13:55:10 +02:00
parent a201dc5798
commit a1bd1c15e2

View file

@ -200,10 +200,12 @@ def _render_kubefiles(
_logger.debug("kubefiles path: %s", kubefiles_path) _logger.debug("kubefiles path: %s", kubefiles_path)
# TODO async copytree, or make this whole _render_kubefiles run_in_executor # TODO async copytree, or make this whole _render_kubefiles run_in_executor
shutil.copytree(kubefiles_path, tmp_path, dirs_exist_ok=True) shutil.copytree(kubefiles_path, tmp_path, dirs_exist_ok=True)
template = Template((tmp_path / "kustomization.yaml.jinja").read_text()) for template_path in tmp_path.rglob("*.jinja"):
(tmp_path / "kustomization.yaml").write_text( template = Template(template_path.read_text())
template_path.with_suffix("").write_text(
template.render(dict(deployment_vars)) template.render(dict(deployment_vars))
) )
template_path.unlink()
yield tmp_path yield tmp_path