New ๐ŸŒŠ wave for @helm

Commit bbd38a84

bbd38a84b080Merged

Svyatoslav Dumchenko <[email protected]> ยท 5 years ago ยท 2 files ยท +1 added ยท ~1 modified

Description

add some tests for pkg/template

Details

Commit
bbd38a84b080
Parent
75f83640ff77

pkg/template/func.gomodifiedView file

@@ -9,6 +9,25 @@
99 "text/template"
1010 )
1111
12+var (
13+ sprigAliases = map[string]string{
14+ "get": "sprigGet",
15+ "hasKey": "sprigHasKey",
16+ }
17+
18+ customFuncs = map[string]interface{}{
19+ "toYaml": ToYaml,
20+ "fromYaml": FromYaml,
21+ "exec": Exec,
22+ "setValueAtPath": SetValueAtPath,
23+ "requiredEnv": RequiredEnv,
24+ "required": Required,
25+ "readFile": ReadFile,
26+ "get": Get,
27+ "hasKey": HasKey,
28+ }
29+)
30+
1231 func Tpl2yml(tpl string, yml string, data interface{}) error {
1332 log.WithFields(log.Fields{
1433 "from": tpl,
@@ -48,30 +67,13 @@
4867 }
4968
5069 func FuncMap() template.FuncMap {
51- aliased := template.FuncMap{}
52-
53- aliases := map[string]string{
54- "get": "sprigGet",
55- "hasKey": "sprigHasKey",
56- }
57-
5870 funcMap := sprig.TxtFuncMap()
5971
60- for orig, alias := range aliases {
61- aliased[alias] = funcMap[orig]
72+ for orig, alias := range sprigAliases {
73+ funcMap[alias] = funcMap[orig]
6274 }
6375
64- funcMap["toYaml"] = ToYaml
65- funcMap["fromYaml"] = FromYaml
66- funcMap["exec"] = Exec
67- funcMap["setValueAtPath"] = SetValueAtPath
68- funcMap["requiredEnv"] = RequiredEnv
69- funcMap["required"] = Required
70- funcMap["readFile"] = ReadFile
71- funcMap["get"] = Get
72- funcMap["hasKey"] = HasKey
73-
74- for name, f := range aliased {
76+ for name, f := range customFuncs {
7577 funcMap[name] = f
7678 }
7779