From 43a6bcff4086255a5410b4d5a9d5bb4f222842db Mon Sep 17 00:00:00 2001 From: Fabian Ruff <fabian@progra.de> Date: Fri, 3 Mar 2017 14:15:07 +0100 Subject: [PATCH] Add .Template.BasePath to template system --- pkg/engine/engine.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 95831ad40..8f4eff127 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -120,6 +120,8 @@ type renderable struct { tpl string // vals are the values to be supplied to the template. vals chartutil.Values + // namespace prefix to the templates of the current chart + basePath string } // alterFuncMap takes the Engine's FuncMap and adds context-specific functions. @@ -178,7 +180,7 @@ func (e *Engine) render(tpls map[string]renderable) (map[string]string, error) { for _, file := range files { // At render time, add information about the template that is being rendered. vals := tpls[file].vals - vals["Template"] = map[string]interface{}{"Name": file} + vals["Template"] = map[string]interface{}{"Name": file, "BasePath": tpls[file].basePath} if err := t.ExecuteTemplate(&buf, file, vals); err != nil { return map[string]string{}, fmt.Errorf("render error in %q: %s", file, err) } @@ -246,8 +248,9 @@ func recAllTpls(c *chart.Chart, templates map[string]renderable, parentVals char } for _, t := range c.Templates { templates[path.Join(newParentID, t.Name)] = renderable{ - tpl: string(t.Data), - vals: cvals, + tpl: string(t.Data), + vals: cvals, + basePath: path.Join(newParentID, "templates"), } } } -- GitLab