From 29641468bd4521d9773ef3a47cce4b4eeb0af720 Mon Sep 17 00:00:00 2001 From: eastagiletracker <310448263+eastagiletracker@users.noreply.github.com> Date: Tue, 29 Sep 2026 19:35:34 +0700 Subject: [PATCH] Render harness envmap in the docker compose target The Helm templates add every harness.envmap entry to the container environment, but auto-compose.yaml only iterated the deprecated harness.env list, so envmap variables were silently dropped from docker-compose.yaml (e.g. all KC_* settings of the accounts application). --- .../compose/templates/auto-compose.yaml | 3 + .../tests/test_dockercompose.py | 55 +++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/deployment-configuration/compose/templates/auto-compose.yaml b/deployment-configuration/compose/templates/auto-compose.yaml index b7d8b17f7..efa88e6af 100644 --- a/deployment-configuration/compose/templates/auto-compose.yaml +++ b/deployment-configuration/compose/templates/auto-compose.yaml @@ -107,6 +107,9 @@ services: {{- range $app_config.harness.env }} - {{ .name }}={{ .value }} {{- end }} + {{- range $name, $value := $app_config.harness.envmap }} + - {{ printf "%s=%v" $name $value | quote }} + {{- end }} {{- if or $app_config.harness.dependencies.hard $app_config.harness.dependencies.soft }} {{- with compact (append (concat (without $app_config.harness.dependencies.hard "argo") diff --git a/tools/deployment-cli-tools/tests/test_dockercompose.py b/tools/deployment-cli-tools/tests/test_dockercompose.py index 154aca7d5..3ba08ac88 100644 --- a/tools/deployment-cli-tools/tests/test_dockercompose.py +++ b/tools/deployment-cli-tools/tests/test_dockercompose.py @@ -165,6 +165,61 @@ def render_proxy_config(): assert inherited_config['enable-pkce'] is False +@pytest.mark.skipif(not HELM_IS_INSTALLED, reason="helm is not installed") +def test_compose_envmap_rendering(tmp_path): + out_folder = tmp_path / 'test_compose_envmap_rendering' + create_docker_compose_configuration( + [CLOUDHARNESS_ROOT, RESOURCES], + output_path=out_folder, + include=['samples'], + domain="my.local", + local=False, + ) + + compose_path = out_folder / COMPOSE_PATH + values_path = compose_path / 'values.yaml' + with open(values_path, 'r') as values_file: + values = yaml.load(values_file) + + def render_samples_environment(): + with open(values_path, 'w') as values_file: + yaml.dump(values, values_file) + completed = subprocess.run( + ['helm', 'template', str(compose_path)], + check=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True, + ) + with StringIO(completed.stdout) as stream: + documents = list(yaml.load_all(stream)) + for document in documents: + if document and 'services' in document: + return document['services']['samples']['environment'] + raise AssertionError('Could not find the docker compose services') + + # envmap entries from the application values.yaml are rendered alongside the (deprecated) env list + environment = render_samples_environment() + assert 'ENVIRONMENT_TEST_A=value' in environment + assert 'ENVIRONMENT_TEST_B=123' in environment + assert 'WORKERS=3' in environment + assert 'CH_CURRENT_APP_NAME=samples' in environment + + # A single key can be overridden without restating the others, and values are quoted + values['apps']['samples']['harness']['envmap']['ENVIRONMENT_TEST_A'] = 'overridden: #1' + values['apps']['samples']['harness']['envmap']['ENVIRONMENT_TEST_C'] = True + environment = render_samples_environment() + assert 'ENVIRONMENT_TEST_A=overridden: #1' in environment + assert 'ENVIRONMENT_TEST_B=123' in environment + assert 'ENVIRONMENT_TEST_C=true' in environment + + # No envmap: only the list-based variables are rendered + del values['apps']['samples']['harness']['envmap'] + environment = render_samples_environment() + assert not [e for e in environment if e.startswith('ENVIRONMENT_TEST_')] + assert 'WORKERS=3' in environment + + def test_compose_app_depends_on_task_only(tmp_path): out_folder = tmp_path / 'test_compose_app_depends_on_task_only'