Enhance CLI output

This commit is contained in:
Ettore Di Giacinto
2020-10-30 19:15:04 +01:00
parent f6a4b634c1
commit 91dfb8ce3a
7 changed files with 39 additions and 36 deletions

View File

@@ -1,15 +1,14 @@
package helpers
import (
"github.com/pkg/errors"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chartutil"
"helm.sh/helm/v3/pkg/engine"
"github.com/pkg/errors"
)
// RenderHelm renders the template string with helm
func RenderHelm(template string, values map[string]interface{}) (string,error) {
func RenderHelm(template string, values map[string]interface{}) (string, error) {
c := &chart.Chart{
Metadata: &chart.Metadata{
Name: "",
@@ -18,17 +17,17 @@ func RenderHelm(template string, values map[string]interface{}) (string,error) {
Templates: []*chart.File{
{Name: "templates", Data: []byte(template)},
},
Values: map[string]interface{}{"Values":values},
Values: map[string]interface{}{"Values": values},
}
v, err := chartutil.CoalesceValues(c, map[string]interface{}{})
if err != nil {
return "",errors.Wrap(err,"while rendering template")
return "", errors.Wrap(err, "while rendering template")
}
out, err := engine.Render(c, v)
if err != nil {
return "",errors.Wrap(err,"while rendering template")
return "", errors.Wrap(err, "while rendering template")
}
return out["templates"],nil
return out["templates"], nil
}