dex/vendor/sigs.k8s.io/testing_frameworks/integration/internal/arguments.go

29 lines
447 B
Go
Raw Normal View History

2020-01-31 15:02:00 +05:30
package internal
import (
"bytes"
"html/template"
)
func RenderTemplates(argTemplates []string, data interface{}) (args []string, err error) {
var t *template.Template
for _, arg := range argTemplates {
t, err = template.New(arg).Parse(arg)
if err != nil {
args = nil
return
}
buf := &bytes.Buffer{}
err = t.Execute(buf, data)
if err != nil {
args = nil
return
}
args = append(args, buf.String())
}
return
}