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"] = ToYaml65-
funcMap["fromYaml"] = FromYaml66-
funcMap["exec"] = Exec67-
funcMap["setValueAtPath"] = SetValueAtPath68-
funcMap["requiredEnv"] = RequiredEnv69-
funcMap["required"] = Required70-
funcMap["readFile"] = ReadFile71-
funcMap["get"] = Get72-
funcMap["hasKey"] = HasKey73-
74-
for name, f := range aliased {76+
for name, f := range customFuncs {7577
funcMap[name] = f7678
}7779
pkg/template/func_test.goaddedView file
Loading diffโฆ