Skip to content

Commit 4b8dfd2

Browse files
committed
remove comments. add link to source
Signed-off-by: tpickett <[email protected]>
1 parent a3fbca0 commit 4b8dfd2

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

function_maps.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,27 +94,19 @@ func setResourceNameAnnotation(name string) string {
9494
}
9595

9696
func initTpl(parent *template.Template, includedNames map[string]int) func(string, interface{}) (string, error) {
97+
//see https://github.com/helm/helm/blob/261233caec499c18602c61ac32507fa4656ebc9b/pkg/engine/engine.go#L148
9798
return func(tpl string, vals interface{}) (string, error) {
9899
t, err := parent.Clone()
99100
t.Option("missingkey=zero")
100101
if err != nil {
101102
return "", errors.Wrapf(err, "cannot clone template")
102103
}
103104

104-
// Re-inject 'include' so that it can close over our clone of t;
105-
// this lets any 'define's inside tpl be 'include'd.
106105
t.Funcs(template.FuncMap{
107-
// "include": includeFun(t, includedNames),
108106
"include": initInclude(t, includedNames),
109107
"tpl": initTpl(t, includedNames),
110108
})
111109

112-
// We need a .New template, as template text which is just blanks
113-
// or comments after parsing out defines just adds new named
114-
// template definitions without changing the main template.
115-
// https://pkg.go.dev/text/template#Template.Parse
116-
// Use the parent's name for lack of a better way to identify the tpl
117-
// text string. (Maybe we could use a hash appended to the name?)
118110
t, err = t.New(parent.Name()).Parse(tpl)
119111
if err != nil {
120112
return "", errors.Wrapf(err, "cannot parse template %q", tpl)
@@ -125,7 +117,6 @@ func initTpl(parent *template.Template, includedNames map[string]int) func(strin
125117
return "", errors.Wrapf(err, "error during tpl function execution for %q", tpl)
126118
}
127119

128-
// See comment in renderWithReferences explaining the <no value> hack.
129120
return strings.ReplaceAll(buf.String(), "<no value>", ""), nil
130121
}
131122
}

0 commit comments

Comments
 (0)