Replacing options interface argument

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

@ -226,7 +226,7 @@ func (s *releaseServer) InstallRelease(c ctx.Context, req *services.InstallRelea
} }
ts := timeconv.Now() 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) valuesToRender, err := chartutil.ToRenderValues(req.Chart, req.Values, options)
if err != nil { if err != nil {
return nil, err return nil, err

@ -24,6 +24,7 @@ import (
"strings" "strings"
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
"github.com/golang/protobuf/ptypes/timestamp"
"k8s.io/helm/pkg/proto/hapi/chart" "k8s.io/helm/pkg/proto/hapi/chart"
) )
@ -288,13 +289,21 @@ func coalesceTables(dst, src map[string]interface{}) map[string]interface{} {
return dst 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 // 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{}{ overrides := map[string]interface{}{
"Release": map[string]interface{}{ "Release": map[string]interface{}{
"Name": options["releaseName"], "Name": options.Name,
"Time": options["releaseTime"], "Time": options.Time,
"Namespace": options["namespace"], "Namespace": options.Namespace,
"Service": "Tiller", "Service": "Tiller",
}, },
"Chart": chrt.Metadata, "Chart": chrt.Metadata,

@ -52,7 +52,7 @@ func Templates(linter *support.Linter) {
return 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) valuesToRender, err := chartutil.ToRenderValues(chart, chart.Values, options)
renderedContentMap, err := engine.New().Render(chart, valuesToRender) renderedContentMap, err := engine.New().Render(chart, valuesToRender)

Loading…
Cancel
Save