Skip to content

Commit 423cfbb

Browse files
committed
fix(api/types): map HelmChartArgs.ReleaseNamespace -> HelmChart.Namespace
SplitHelmParameters goes through makeHelmChartFromHca to translate the deprecated HelmChartArgs into the current HelmChart type. That mapping forgot to copy ReleaseNamespace onto Namespace, so kustomiz- ations that used the deprecated helmChartInflationGenerator field with releaseNamespace silently rendered every resource into the default namespace instead of the requested one. HelmChartArgs is documented as deprecated, but kustomize still supports it, and the rendering bug is visible: users follow the docs for releaseNamespace and get a kustomization that emits the wrong namespace with no warning. The fix is one line — copy ReleaseNamespace onto Namespace in makeHelmChartFromHca — plus a regression test under TestSplitHelmParametersPropagatesReleaseNamespace that pins the mapping so the bug cannot silently regress. Fixes #4593 Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
1 parent 72b0fd1 commit 423cfbb

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

api/types/helmchartargs.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ func makeHelmChartFromHca(old *HelmChartArgs) (c HelmChart) {
148148
c.ValuesInline = old.ValuesLocal
149149
c.ValuesMerge = old.ValuesMerge
150150
c.ReleaseName = old.ReleaseName
151+
// ReleaseNamespace maps onto Namespace in the (non-deprecated)
152+
// HelmChart type. Forgetting this mapping is why releaseNamespace
153+
// set under the deprecated helmChartInflationGenerator field is
154+
// silently ignored — see kubernetes-sigs/kustomize#4593.
155+
c.Namespace = old.ReleaseNamespace
151156
return
152157
}
153158

api/types/helmchartargs_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,23 @@ func TestAsHelmArgs(t *testing.T) {
102102
"--devel"})
103103
})
104104
}
105+
106+
// Regression test for https://github.com/kubernetes-sigs/kustomize/issues/4593.
107+
// HelmChartArgs.ReleaseNamespace was not copied into HelmChart.Namespace by
108+
// makeHelmChartFromHca, so kustomizations that used the deprecated
109+
// helmChartInflationGenerator with releaseNamespace silently rendered resources
110+
// into the "default" namespace.
111+
func TestSplitHelmParametersPropagatesReleaseNamespace(t *testing.T) {
112+
args := []types.HelmChartArgs{{
113+
ChartName: "nats",
114+
ChartVersion: "v0.13.1",
115+
ReleaseName: "nats",
116+
ReleaseNamespace: "custom-ns",
117+
}}
118+
119+
charts, _ := types.SplitHelmParameters(args)
120+
121+
require.Len(t, charts, 1)
122+
require.Equal(t, "custom-ns", charts[0].Namespace,
123+
"ReleaseNamespace from the deprecated HelmChartArgs must map onto HelmChart.Namespace")
124+
}

0 commit comments

Comments
 (0)