Fix issue with precedence of imports. Imports in parent did not override values in subcharts

Signed-off-by: Tore Johansson <github@tore.cc>
pull/12590/head
Tore Johansson 11 months ago
parent d1595e701f
commit f1e722a2a4

@ -303,8 +303,10 @@ func processImportValues(c *chart.Chart, merge bool) error {
if merge {
// deep copying the cvals as there are cases where pointers can end
// up in the cvals when they are copied onto b in ways that break things.
cvals = deepCopyMap(cvals)
c.Values = MergeTables(cvals, b)
// Merge dependencies in the chart values-file first
b = MergeTables(deepCopyMap(c.Values), b)
// next merge sub-chart values in the chart-values merged with the dependencies
c.Values = MergeTables(deepCopyMap(b), cvals)
} else {
// Trimming the nil values from cvals is needed for backwards compatibility.
// Previously, the b value had been populated with cvals along with some

@ -290,10 +290,19 @@ func TestProcessDependencyImportValuesMultiLevelPrecedence(t *testing.T) {
// chart. The library chart value should be used.
// - app4 has a value in the app chart and does not import the value from the
// library chart. The app charts value should be used.
// - app5 has no value in the app chart and does not import the value. Umbrella import values
// The umbrella import value should be used.
// - app6 has null value in the app chart and does not import the value. Umbrella import values
// The app umbrella import value should be used.
// - app7 has a value in the app chart and does not import the value. Umbrella import values
// The app umbrella import value should be used.
e["app1.service.port"] = "3456"
e["app2.service.port"] = "8080"
e["app3.service.port"] = "9090"
e["app4.service.port"] = "1234"
e["app5.service.port"] = "9090"
e["app6.service.port"] = "9090"
e["app7.service.port"] = "9090"
if err := processDependencyImportValues(c, true); err != nil {
t.Fatalf("processing import values dependencies %v", err)
}

@ -17,3 +17,18 @@ dependencies:
- name: app4
version: 0.1.0
condition: app4.enabled
- name: app5
version: 0.1.0
condition: app5.enabled
- name: app6
version: 0.1.0
condition: app5.enabled
- name: app7
version: 0.1.0
condition: app5.enabled
- name: values
condition: profile.enabled
import-values:
- defaults
repository: file://charts/values
version: 0.1.0

@ -0,0 +1,5 @@
apiVersion: v2
name: app5
description: A Helm chart for Kubernetes
type: application
version: 0.1.0

@ -0,0 +1,5 @@
apiVersion: v2
name: app6
description: A Helm chart for Kubernetes
type: application
version: 0.1.0

@ -0,0 +1,5 @@
apiVersion: v2
name: app7
description: A Helm chart for Kubernetes
type: application
version: 0.1.0

@ -0,0 +1,5 @@
apiVersion: v2
name: values
description: A Helm chart for Kubernetes
type: library
version: 0.1.0

@ -0,0 +1,14 @@
exports:
defaults:
app5:
service:
type: ClusterIP
port: 9090
app6:
service:
type: ClusterIP
port: 9090
app7:
service:
type: ClusterIP
port: 9090

@ -12,3 +12,15 @@ app3:
app4:
enabled: true
app5:
enabled: true
app6:
enabled: true
app7:
enabled: true
profile:
enabled: true
Loading…
Cancel
Save