diff --git a/cmd/tiller/release_server.go b/cmd/tiller/release_server.go index 770231ade..e4f84facf 100644 --- a/cmd/tiller/release_server.go +++ b/cmd/tiller/release_server.go @@ -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 diff --git a/pkg/chartutil/values.go b/pkg/chartutil/values.go index c209f5f13..b14bc23ba 100644 --- a/pkg/chartutil/values.go +++ b/pkg/chartutil/values.go @@ -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, diff --git a/pkg/lint/rules/template.go b/pkg/lint/rules/template.go index 9ea80e6a0..0291d401d 100644 --- a/pkg/lint/rules/template.go +++ b/pkg/lint/rules/template.go @@ -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)