Skip to content

Commit 0d8e087

Browse files
committed
Fix docker compose missing template functions
1 parent fdf232e commit 0d8e087

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

tools/deployment-cli-tools/ch_cli_tools/configurationgenerator.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,14 @@ def collect_apps_helm_templates(search_root, dest_helm_chart_path, templates_pat
597597
app_name = app_name_from_path(os.path.relpath(f"{app_path}", app_base_path))
598598
if app_name in exclude or (include and not any(inc in app_name for inc in include)):
599599
continue
600+
601+
# Determine which template directory to use
602+
regular_template_dir = app_path / 'deploy' / 'templates'
600603
if templates_path == HELM_PATH:
601-
template_dir = app_path / 'deploy' / 'templates'
604+
template_dir = regular_template_dir
602605
else:
603606
template_dir = app_path / 'deploy' / f'templates-{templates_path}'
607+
604608
if template_dir.exists():
605609
dest_dir = dest_helm_chart_path / 'templates' / app_name
606610

@@ -615,6 +619,21 @@ def collect_apps_helm_templates(search_root, dest_helm_chart_path, templates_pat
615619
if envs:
616620
merge_configuration_directories(f"{dest_dir}", f"{dest_dir}", envs)
617621

622+
# For non-helm mode (e.g., compose), also copy helper templates (_*.tpl) from regular
623+
# templates directory. These are needed because resources (e.g., realm.json) may reference
624+
# template helpers defined there.
625+
if templates_path != HELM_PATH and regular_template_dir.exists():
626+
helper_files = list(regular_template_dir.glob("_*.tpl"))
627+
if helper_files:
628+
dest_dir = dest_helm_chart_path / 'templates' / app_name
629+
dest_dir.mkdir(parents=True, exist_ok=True)
630+
logging.info(
631+
"Collecting helper templates for application %s to %s", app_name, dest_dir)
632+
for helper_file in helper_files:
633+
dest_file = dest_dir / helper_file.name
634+
if not dest_file.exists(): # Don't overwrite if templates-{path} provided one
635+
shutil.copy(helper_file, dest_file)
636+
618637
resources_dir = app_path / 'deploy' / 'resources'
619638
if resources_dir.exists():
620639
dest_dir = dest_helm_chart_path / 'resources' / app_name

0 commit comments

Comments
 (0)