fix(helm): process dependencies import-values

When running helm lint, import-values for dependencies are ignored,
also added test for linting chart with import-values

Closes #9658

Signed-off-by: Stuart Drennan <stuart.drennan@gmail.com>
pull/10271/head
Stuart Drennan 3 years ago
parent 83791fe7c2
commit 1931b0702d

@ -35,6 +35,7 @@ const badChartDir = "rules/testdata/badchartfile"
const badValuesFileDir = "rules/testdata/badvaluesfile"
const badYamlFileDir = "rules/testdata/albatross"
const goodChartDir = "rules/testdata/goodone"
const subChartValuesDir = "rules/testdata/withsubchart"
func TestBadChart(t *testing.T) {
m := All(badChartDir, values, namespace, strict).Messages
@ -144,3 +145,15 @@ func TestHelmCreateChart(t *testing.T) {
t.Errorf("Unexpected lint error: %s", msg)
}
}
// lint ignores import-values
// See https://github.com/helm/helm/issues/9658
func TestSubChartValuesChart(t *testing.T) {
m := All(subChartValuesDir, values, namespace, strict).Messages
if len(m) != 0 {
t.Error("All returned linter messages when it shouldn't have")
for i, msg := range m {
t.Logf("Message %d: %s", i, msg)
}
}
}

@ -70,6 +70,12 @@ func Templates(linter *support.Linter, values map[string]interface{}, namespace
Namespace: namespace,
}
// lint ignores import-values
// See https://github.com/helm/helm/issues/9658
if err := chartutil.ProcessDependencies(chart, values); err != nil {
return
}
cvals, err := chartutil.CoalesceValues(chart, values)
if err != nil {
return

@ -0,0 +1,16 @@
apiVersion: v2
name: withsubchart
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: "1.16.0"
icon: http://riverrun.io
dependencies:
- name: subchart
version: 0.1.16
repository: "file://../subchart"
import-values:
- child: subchart
parent: subchart

@ -0,0 +1,6 @@
apiVersion: v2
name: subchart
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: "1.16.0"

@ -0,0 +1,2 @@
metadata:
name: {{ .Values.subchart.name | lower }}

@ -0,0 +1,2 @@
metadata:
name: {{ .Values.subchart.name | lower }}
Loading…
Cancel
Save