Replacing options interface argument

pull/899/head
Miguel Martinez 8 years ago
parent 7bb4893cad
commit 12aa72f121

@ -226,7 +226,7 @@ func (s *releaseServer) InstallRelease(c ctx.Context, req *services.InstallRelea
}
ts := timeconv.Now()
options := map[string]interface{}{"namespace": s.env.Namespace, "releaseName": name, "releaseTime": ts}
options := chartutil.ReleaseOptions{Name: name, Time: ts, Namespace: s.env.Namespace}
valuesToRender, err := chartutil.ToRenderValues(req.Chart, req.Values, options)
if err != nil {
return nil, err

@ -24,6 +24,7 @@ import (
"strings"
"github.com/ghodss/yaml"
"github.com/golang/protobuf/ptypes/timestamp"
"k8s.io/helm/pkg/proto/hapi/chart"
)
@ -288,13 +289,21 @@ func coalesceTables(dst, src map[string]interface{}) map[string]interface{} {
return dst
}
// ReleaseOptions represents the additional release options needed
// for the composition of the final values struct
type ReleaseOptions struct {
Name string
Time *timestamp.Timestamp
Namespace string
}
// ToRenderValues composes the struct from the data coming from the Releases, Charts and Values files
func ToRenderValues(chrt *chart.Chart, chrtVals *chart.Config, options map[string]interface{}) (Values, error) {
func ToRenderValues(chrt *chart.Chart, chrtVals *chart.Config, options ReleaseOptions) (Values, error) {
overrides := map[string]interface{}{
"Release": map[string]interface{}{
"Name": options["releaseName"],
"Time": options["releaseTime"],
"Namespace": options["namespace"],
"Name": options.Name,
"Time": options.Time,
"Namespace": options.Namespace,
"Service": "Tiller",
},
"Chart": chrt.Metadata,

@ -52,7 +52,7 @@ func Templates(linter *support.Linter) {
return
}
options := map[string]interface{}{"namespace": "testNamespace", "releaseName": "testRelease", "releaseTime": timeconv.Now()}
options := chartutil.ReleaseOptions{Name: "testRelease", Time: timeconv.Now(), Namespace: "testNamespace"}
valuesToRender, err := chartutil.ToRenderValues(chart, chart.Values, options)
renderedContentMap, err := engine.New().Render(chart, valuesToRender)

Loading…
Cancel
Save