Commit 8c720ee2 authored by Justin Scott's avatar Justin Scott

fix (pkg/chartutil): correctly parse input values for ProcessRequirementsEnabled

Fixes a bug where tags and conditions specified in values.yaml were not being respeceted, causing incorrect loading of subcharts.

Closes #2139
parent 6d5b3bbb
...@@ -236,10 +236,15 @@ func ProcessRequirementsEnabled(c *chart.Chart, v *chart.Config) error { ...@@ -236,10 +236,15 @@ func ProcessRequirementsEnabled(c *chart.Chart, v *chart.Config) error {
if err != nil { if err != nil {
return err return err
} }
// convert our values back into config
yvals, err := cvals.YAML()
if err != nil {
return err
}
cc := chart.Config{Raw: yvals}
// flag dependencies as enabled/disabled // flag dependencies as enabled/disabled
ProcessRequirementsTags(reqs, cvals) ProcessRequirementsTags(reqs, cvals)
ProcessRequirementsConditions(reqs, cvals) ProcessRequirementsConditions(reqs, cvals)
// make a map of charts to remove // make a map of charts to remove
rm := map[string]bool{} rm := map[string]bool{}
for _, r := range reqs.Dependencies { for _, r := range reqs.Dependencies {
...@@ -259,7 +264,7 @@ func ProcessRequirementsEnabled(c *chart.Chart, v *chart.Config) error { ...@@ -259,7 +264,7 @@ func ProcessRequirementsEnabled(c *chart.Chart, v *chart.Config) error {
} }
// recursively call self to process sub dependencies // recursively call self to process sub dependencies
for _, t := range cd { for _, t := range cd {
err := ProcessRequirementsEnabled(t, v) err := ProcessRequirementsEnabled(t, &cc)
// if its not just missing requirements file, return error // if its not just missing requirements file, return error
if nerr, ok := err.(ErrNoRequirementsFile); !ok && err != nil { if nerr, ok := err.(ErrNoRequirementsFile); !ok && err != nil {
return nerr return nerr
......
...@@ -74,15 +74,16 @@ func TestRequirementsTagsEnabledL1(t *testing.T) { ...@@ -74,15 +74,16 @@ func TestRequirementsTagsEnabledL1(t *testing.T) {
verifyRequirementsEnabled(t, c, v, e) verifyRequirementsEnabled(t, c, v, e)
} }
func TestRequirementsTagsDisabledL2(t *testing.T) { func TestRequirementsTagsDisabledL2(t *testing.T) {
c, err := Load("testdata/subpop") c, err := Load("testdata/subpop")
if err != nil { if err != nil {
t.Fatalf("Failed to load testdata: %s", err) t.Fatalf("Failed to load testdata: %s", err)
} }
// tags disabling only children // tags disabling only children, children still enabled since tag front-end=true in values.yaml
v := &chart.Config{Raw: "tags:\n subcharta: false\n\n subchartb: false\n"} v := &chart.Config{Raw: "tags:\n subcharta: false\n\n subchartb: false\n"}
// expected charts including duplicates in alphanumeric order // expected charts including duplicates in alphanumeric order
e := []string{"parentchart", "subchart1"} e := []string{"parentchart", "subchart1", "subcharta", "subchartb"}
verifyRequirementsEnabled(t, c, v, e) verifyRequirementsEnabled(t, c, v, e)
} }
...@@ -115,10 +116,10 @@ func TestRequirementsConditionsEnabledL1Both(t *testing.T) { ...@@ -115,10 +116,10 @@ func TestRequirementsConditionsEnabledL1Both(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("Failed to load testdata: %s", err) t.Fatalf("Failed to load testdata: %s", err)
} }
// conditions enabling the parent charts, effectively enabling children // conditions enabling the parent charts, but back-end (b, c) is still disabled via values.yaml
v := &chart.Config{Raw: "subchart1:\n enabled: true\nsubchart2:\n enabled: true\n"} v := &chart.Config{Raw: "subchart1:\n enabled: true\nsubchart2:\n enabled: true\n"}
// expected charts including duplicates in alphanumeric order // expected charts including duplicates in alphanumeric order
e := []string{"parentchart", "subchart1", "subchart2", "subcharta", "subchartb", "subchartb", "subchartc"} e := []string{"parentchart", "subchart1", "subchart2", "subcharta", "subchartb"}
verifyRequirementsEnabled(t, c, v, e) verifyRequirementsEnabled(t, c, v, e)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment