feat(templater): Add insertTemplate function
Similar to insertFile, but runs the templating against the file before inserting. This is useful for sharing common config between yaml files, e.g. volume mounts in a deployment.yaml and cronjob.yaml, and it's useful to be able to use the `configHash` annotation pattern with a templated configmap.yaml
This commit is contained in:
parent
8abe03de3c
commit
6353ed9d14
2 changed files with 11 additions and 1 deletions
|
|
@ -205,6 +205,14 @@ func templateFuncs(c *context.Context, rs *context.ResourceSet) template.FuncMap
|
|||
|
||||
return string(data), nil
|
||||
}
|
||||
m["insertTemplate"] = func(file string) (string, error) {
|
||||
data, err := templateFile(c, rs, path.Join(rs.Path, file))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return data.Rendered, nil
|
||||
}
|
||||
m["default"] = func(defaultVal interface{}, varName string) interface{} {
|
||||
if val, ok := rs.Values[varName]; ok {
|
||||
return val
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue