From 39119bb8b132d82df58b9a8170444c38d86d88ef Mon Sep 17 00:00:00 2001 From: Guilherme Moreira Rodrigues Date: Wed, 21 Oct 2026 10:27:28 -0300 Subject: [PATCH] feat(dispatch-helm): leave components mapped to null out of the chart update An extra_builds image the chart does not deploy (a test mock, for example) had no way out of the central Helm dispatch: unmapped components fall back to their own name as the values key, so helm-update-chart wrote .image.tag at the root of values.yaml, where nothing reads it (seen in LerianStudio/helm#2554 with plugin-br-bank-transfer-mock-jd). A component mapped to null in values_key_mappings / helm_values_key_mappings is now skipped. Unmapped components keep the old fallback, so existing callers are unaffected. Docs also note that nested keys (app.migrations) are allowed. --- .github/workflows/dispatch-helm.yml | 12 +++++++++++- docs/dispatch-helm.md | 2 +- docs/go-release.md | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dispatch-helm.yml b/.github/workflows/dispatch-helm.yml index dc3f41d5..e703578f 100644 --- a/.github/workflows/dispatch-helm.yml +++ b/.github/workflows/dispatch-helm.yml @@ -86,7 +86,7 @@ on: type: boolean default: true values_key_mappings: - description: 'JSON mapping of component names to values.yaml keys. If not mapped, uses component name as fallback.' + description: 'JSON mapping of component names to values.yaml keys. If not mapped, uses component name as fallback. Map a component to null to leave it out of the chart update.' type: string default: '' legacy_patch_detection: @@ -350,6 +350,16 @@ jobs: # Process each component for row in $(echo "$COMPONENTS_JSON" | jq -c '.[]'); do COMP_NAME=$(echo "$row" | jq -r '.name') + + # A component mapped to null in values_key_mappings has no place in + # the chart (a test mock image, a sidecar the chart does not deploy): + # leave it out of the payload. Unmapped components still fall back to + # their own name as the values key, which is a root-level key. + if [ -n "$VALUES_KEY_MAPPINGS" ] && \ + echo "$VALUES_KEY_MAPPINGS" | jq -e --arg name "$COMP_NAME" 'type == "object" and has($name) and .[$name] == null' >/dev/null 2>&1; then + echo "Skipping ${COMP_NAME}: mapped to null in values_key_mappings" + continue + fi COMP_PATH=$(echo "$row" | jq -r '.path // empty') COMP_VERSION=$(echo "$row" | jq -r '.version // empty') diff --git a/docs/dispatch-helm.md b/docs/dispatch-helm.md index d76e0f1b..3f1b9e07 100644 --- a/docs/dispatch-helm.md +++ b/docs/dispatch-helm.md @@ -25,7 +25,7 @@ It also classifies the release: when the tag being dispatched was cut from a mai | `components_base_path` | Base path for components in the source repository | no | `components` | | `env_file` | Env example file relative to the component path | no | `.env.example` | | `detect_env_changes` | Detect environment variables added since the previous release | no | `true` | -| `values_key_mappings` | JSON mapping of component names to `values.yaml` keys | no | `''` | +| `values_key_mappings` | JSON mapping of component names to `values.yaml` keys. A key may be nested (`app.migrations` writes `app.migrations.image.tag`). Map a component to `null` to leave it out of the chart update (e.g. a test mock image the chart does not deploy); an unmapped component falls back to its own name as a root-level key | no | `''` | | `legacy_patch_detection` | Flag releases cut from maintenance branches as legacy patches | no | `true` | | `legacy_branch_patterns` | Glob patterns (newline or comma separated) of maintenance branches | no | `maintenance/*` | | `runner_type` | GitHub runner type | no | `blacksmith-4vcpu-ubuntu-2404` | diff --git a/docs/go-release.md b/docs/go-release.md index 7414269a..8690e147 100644 --- a/docs/go-release.md +++ b/docs/go-release.md @@ -58,7 +58,7 @@ A third layout needs `release_single_app: true`: **one semantic-release tag for | `helm_chart` | Helm chart name to update (required when `enable_helm_dispatch`) | string | `''` | | `helm_detect_env_changes` | Detect new environment variables for Helm during dispatch | boolean | `true` | | `helm_env_file` | Example env file `helm_detect_env_changes` reads, relative to each component path. Set it when the repository keeps its example env elsewhere (e.g. `config/.env.example`) — otherwise detection finds nothing. Per-group override: `helm_env_file` | string | `.env.example` | -| `helm_values_key_mappings` | JSON mapping of component names to values.yaml keys | string | `''` | +| `helm_values_key_mappings` | JSON mapping of component names to values.yaml keys (nested keys allowed; `null` leaves a component out of the chart update) | string | `''` | | `extra_builds` | JSON array of additional build groups, each forwarded to `build.yml` with its own config; all feed the single gitops-update (see [Multiple build groups](#multiple-build-groups)) | string | `''` | | `dockerfile_name` | Dockerfile name for the primary build and every `extra_builds` group (per-group override via the group's own `dockerfile_name`); forwarded to `build.yml`, which resolves the path as `{working_dir}/{dockerfile_name}` | string | `'Dockerfile'` | | `enable_goreleaser` | Publish binaries with GoReleaser from the repository `.goreleaser.yml`, instead of (or in addition to) container images (see [GoReleaser binary lane](#goreleaser-binary-lane)) | boolean | `false` |