Skip to content

Commit

Permalink
Extend funcMap for templates with envMapToK8SFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
m-schieder authored and normanjaeckel committed Jul 12, 2024
1 parent f5a2f16 commit f431753
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ var marshalContentFunc = func(ws int, v interface{}) (string, error) {
result = strings.TrimRight(result, "\n")
return result, nil
}
var envMapToK8SFunc = func(v map[string]string) interface{} {
var listOfMaps []map[string]string
for key, value := range v {
m := make(map[string]string)
m["name"] = key
m["value"] = value
listOfMaps = append(listOfMaps, m)
}
return listOfMaps
}
var checkFlagFunc = func(v interface{}) (bool, error) {
f, ok := v.(*bool)
if !ok {
Expand Down Expand Up @@ -84,6 +94,7 @@ var readFileFunc = func(s string) (string, error) {

var funcMap = template.FuncMap{
"marshalContent": marshalContentFunc,
"envMapToK8S": envMapToK8SFunc,
"checkFlag": checkFlagFunc,
"base64Encode": base64EncodeFunc,
"base64Decode": base64DecodeFunc,
Expand Down

0 comments on commit f431753

Please sign in to comment.