diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 77b25140d..4d3c8b315 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -104,13 +104,16 @@ func (e *Engine) render(tpls map[string]string, v interface{}) (map[string]strin // allTemplates returns all templates for a chart and its dependencies. func allTemplates(c *chart.Chart) map[string]string { templates := map[string]string{} + recAllTpls(c, templates) + return templates +} + +func recAllTpls(c *chart.Chart, templates map[string]string) { for _, child := range c.Dependencies { - for _, t := range child.Templates { - templates[t.Name] = string(t.Data) - } + recAllTpls(child, templates) } for _, t := range c.Templates { templates[t.Name] = string(t.Data) } - return templates + } diff --git a/pkg/engine/engine_test.go b/pkg/engine/engine_test.go index 006a91bcd..36992a1f2 100644 --- a/pkg/engine/engine_test.go +++ b/pkg/engine/engine_test.go @@ -90,16 +90,23 @@ func TestAllTemplates(t *testing.T) { {Name: "bar", Data: []byte("bar")}, }, Dependencies: []*chart.Chart{ - {Templates: []*chart.Template{ - {Name: "pinky", Data: []byte("pinky")}, - {Name: "brain", Data: []byte("brain")}, - }}, + { + Templates: []*chart.Template{ + {Name: "pinky", Data: []byte("pinky")}, + {Name: "brain", Data: []byte("brain")}, + }, + Dependencies: []*chart.Chart{ + {Templates: []*chart.Template{ + {Name: "innermost", Data: []byte("innermost")}, + }}, + }, + }, }, } tpls := allTemplates(ch1) - if len(tpls) != 4 { - t.Errorf("Expected 4 charts, got %d", len(tpls)) + if len(tpls) != 5 { + t.Errorf("Expected 5 charts, got %d", len(tpls)) } } @@ -112,9 +119,11 @@ func TestRenderDependency(t *testing.T) { {Name: "outer", Data: []byte(toptpl)}, }, Dependencies: []*chart.Chart{ - {Templates: []*chart.Template{ - {Name: "inner", Data: []byte(deptpl)}, - }}, + { + Templates: []*chart.Template{ + {Name: "inner", Data: []byte(deptpl)}, + }, + }, }, }