|
|
@ -24,6 +24,8 @@ import (
|
|
|
|
"text/template"
|
|
|
|
"text/template"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/Masterminds/sprig"
|
|
|
|
"github.com/Masterminds/sprig"
|
|
|
|
|
|
|
|
"github.com/ghodss/yaml"
|
|
|
|
|
|
|
|
|
|
|
|
"k8s.io/helm/pkg/chartutil"
|
|
|
|
"k8s.io/helm/pkg/chartutil"
|
|
|
|
"k8s.io/helm/pkg/proto/hapi/chart"
|
|
|
|
"k8s.io/helm/pkg/proto/hapi/chart"
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -49,11 +51,23 @@ func New() *Engine {
|
|
|
|
f := sprig.TxtFuncMap()
|
|
|
|
f := sprig.TxtFuncMap()
|
|
|
|
delete(f, "env")
|
|
|
|
delete(f, "env")
|
|
|
|
delete(f, "expandenv")
|
|
|
|
delete(f, "expandenv")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add a function to convert to YAML:
|
|
|
|
|
|
|
|
f["toYaml"] = toYaml
|
|
|
|
return &Engine{
|
|
|
|
return &Engine{
|
|
|
|
FuncMap: f,
|
|
|
|
FuncMap: f,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func toYaml(v interface{}) string {
|
|
|
|
|
|
|
|
data, err := yaml.Marshal(v)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
// Swallow errors inside of a template.
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return string(data)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Render takes a chart, optional values, and value overrides, and attempts to render the Go templates.
|
|
|
|
// Render takes a chart, optional values, and value overrides, and attempts to render the Go templates.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Render can be called repeatedly on the same engine.
|
|
|
|
// Render can be called repeatedly on the same engine.
|
|
|
|