Skip to content

Commit 274c506

Browse files
committed
add convert function
1 parent 32fb631 commit 274c506

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

utils/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
// Version of rivendell
15-
var Version = "1.1.4"
15+
var Version = "1.1.5"
1616

1717
// MergeMaps merges multiple maps into one
1818
func MergeMaps(maps ...map[string]string) map[string]string {

utils/templater.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func ExecuteTemplate(templateFile string, variables map[string]string) ([]byte,
3737
"hash": hashFunc,
3838
"base64": base64Func,
3939
"asGenericMap": asGenericMap,
40+
"asMapString": asMapString,
4041
}).
4142
Parse(contentWithEnvExpand)
4243
if err != nil {
@@ -124,3 +125,16 @@ func asGenericMap(m map[string]string) map[string]interface{} {
124125
}
125126
return ret
126127
}
128+
129+
func asMapString(m map[string]interface{}) map[string]string {
130+
ret := make(map[string]string)
131+
for k, v := range m {
132+
if strVal, ok := v.(string); ok {
133+
ret[k] = strVal
134+
}
135+
if strg, ok := v.(fmt.Stringer); ok {
136+
ret[k] = strg.String()
137+
}
138+
}
139+
return ret
140+
}

0 commit comments

Comments
 (0)