@@ -1227,6 +1227,76 @@ metadata:
12271227` )
12281228}
12291229
1230+ // Regression test: verify that HelmCharts in base kustomizations
1231+ // still receive namespace from overlay after fixing namespace propagation issues.
1232+ // This test ensures the fix for https://github.com/kubernetes-sigs/kustomize/issues/6031
1233+ // and https://github.com/kubernetes-sigs/kustomize/issues/6027
1234+ // does not break the HelmChart namespace propagation feature from
1235+ // https://github.com/kubernetes-sigs/kustomize/issues/5566
1236+ func TestHelmChartNamespacePropagationViaResourcesThreeLevels (t * testing.T ) {
1237+ th := kusttest_test .MakeEnhancedHarnessWithTmpRoot (t )
1238+ defer th .Reset ()
1239+ if err := th .ErrIfNoHelm (); err != nil {
1240+ t .Skip ("skipping: " + err .Error ())
1241+ }
1242+
1243+ // Create base directory with helm chart (Level 1)
1244+ baseDir := th .MkDir ("base" )
1245+ chartDir := filepath .Join (baseDir , "charts" , "service" )
1246+ require .NoError (t , th .GetFSys ().MkdirAll (filepath .Join (chartDir , "templates" )))
1247+ th .WriteF (filepath .Join (chartDir , "Chart.yaml" ), `
1248+ apiVersion: v2
1249+ name: service
1250+ type: application
1251+ version: 1.0.0
1252+ ` )
1253+ th .WriteF (filepath .Join (chartDir , "values.yaml" ), `` )
1254+ th .WriteF (filepath .Join (chartDir , "templates" , "service.yaml" ), `
1255+ apiVersion: v1
1256+ kind: Service
1257+ metadata:
1258+ name: test-service
1259+ namespace: {{ .Release.Namespace }}
1260+ annotations:
1261+ helm-namespace: {{ .Release.Namespace }}
1262+ ` )
1263+
1264+ // Base kustomization with helmCharts (no namespace)
1265+ th .WriteK (baseDir , `
1266+ helmGlobals:
1267+ chartHome: ./charts
1268+ helmCharts:
1269+ - name: service
1270+ releaseName: service
1271+ ` )
1272+
1273+ // Mid-layer that references base via resources (no namespace) (Level 2)
1274+ midDir := th .MkDir ("mid" )
1275+ th .WriteK (midDir , `
1276+ namePrefix: mid-
1277+ resources:
1278+ - ../base
1279+ ` )
1280+
1281+ // Top overlay that references mid-layer and sets namespace (Level 3)
1282+ overlayDir := th .MkDir ("overlay" )
1283+ th .WriteK (overlayDir , `
1284+ namespace: production
1285+ resources:
1286+ - ../mid
1287+ ` )
1288+
1289+ m := th .Run (overlayDir , th .MakeOptionsPluginsEnabled ())
1290+ th .AssertActualEqualsExpected (m , `apiVersion: v1
1291+ kind: Service
1292+ metadata:
1293+ annotations:
1294+ helm-namespace: production
1295+ name: mid-test-service
1296+ namespace: production
1297+ ` )
1298+ }
1299+
12301300func copyValuesFilesTestChartsIntoHarness (t * testing.T , th * kusttest_test.HarnessEnhanced ) {
12311301 t .Helper ()
12321302
0 commit comments