mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-22 07:51:01 +02:00
fix: pass --kube-context to helm template when using jsonPatches (#2309) When using jsonPatches or strategicMergePatches in helmfile, the `helm template` command was not receiving the `--kube-context` flag. This caused issues when `--dry-run=server` was used (introduced in PR #2271 to support lookup() functions), because helm would connect to the wrong cluster context. Root Cause: 1. `flagsForTemplate()` did not call `appendConnectionFlags()`, unlike `flagsForUpgrade()` and `flagsForDiff()` which both include this call. 2. `processChartification()` did not include `--kube-context` when setting `chartifyOpts.TemplateArgs` for internal helm template calls. Fix: 1. Added `appendConnectionFlags()` call to `flagsForTemplate()` to ensure kube-context and other connection flags are passed to helm template. 2. Added `getKubeContext()` helper function that resolves kube-context with proper priority: release > environment > helmDefaults. 3. Modified `processChartification()` to include `--kube-context` in chartifyOpts.TemplateArgs when chartify needs to run helm template. 4. Added compatibility check for `--validate` flag to avoid Helm 4 mutual exclusion error between --validate and --dry-run (Issue #2355). Fixes #2309 Signed-off-by: Aditya Menon <amenon@canarytechnologies.com>
31 lines
652 B
Go Template
31 lines
652 B
Go Template
# Issue #2309: helm template should receive --kube-context when using jsonPatches
|
|
# https://github.com/helmfile/helmfile/issues/2309
|
|
helmDefaults:
|
|
kubeContext: test-context
|
|
|
|
repositories:
|
|
- name: incubator
|
|
url: https://charts.helm.sh/incubator
|
|
---
|
|
releases:
|
|
- name: test-release
|
|
chart: incubator/raw
|
|
namespace: default
|
|
values:
|
|
- resources:
|
|
- apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: test-configmap
|
|
data:
|
|
key: value
|
|
jsonPatches:
|
|
- target:
|
|
version: v1
|
|
kind: ConfigMap
|
|
name: test-configmap
|
|
patch:
|
|
- op: add
|
|
path: /data/patched
|
|
value: "true"
|