From 3508cebbf67304f6e7e210229fcb4f01508c5fa8 Mon Sep 17 00:00:00 2001 From: Kazuki Suda Date: Mon, 11 Sep 2017 10:09:42 +0900 Subject: [PATCH] Use the same defaults as done in helm lint for Capabilities --- cmd/helm/template.go | 8 +++++++- pkg/chartutil/capabilities.go | 18 ++++++++++++++++-- pkg/lint/rules/template.go | 12 ++---------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 88ca92fc9..76c995d17 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -35,6 +35,7 @@ import ( util "k8s.io/helm/pkg/releaseutil" "k8s.io/helm/pkg/tiller" "k8s.io/helm/pkg/timeconv" + tversion "k8s.io/helm/pkg/version" ) const templateDesc = ` @@ -171,7 +172,12 @@ func (t *templateCmd) run(cmd *cobra.Command, args []string) error { // Set up engine. renderer := engine.New() - vals, err := chartutil.ToRenderValues(c, config, options) + caps := &chartutil.Capabilities{ + APIVersions: chartutil.DefaultVersionSet, + KubeVersion: chartutil.DefaultKubeVersion, + TillerVersion: tversion.GetVersionProto(), + } + vals, err := chartutil.ToRenderValuesCaps(c, config, options, caps) if err != nil { return err } diff --git a/pkg/chartutil/capabilities.go b/pkg/chartutil/capabilities.go index 82e5e0c0e..e415306d4 100644 --- a/pkg/chartutil/capabilities.go +++ b/pkg/chartutil/capabilities.go @@ -16,12 +16,26 @@ limitations under the License. package chartutil import ( + "fmt" + "runtime" + "k8s.io/apimachinery/pkg/version" tversion "k8s.io/helm/pkg/proto/hapi/version" ) -// DefaultVersionSet is the default version set, which includes only Core V1 ("v1"). -var DefaultVersionSet = NewVersionSet("v1") +var ( + // DefaultVersionSet is the default version set, which includes only Core V1 ("v1"). + DefaultVersionSet = NewVersionSet("v1") + + // DefaultKubeVersion is the default kubernetes version + DefaultKubeVersion = &version.Info{ + Major: "1", + Minor: "7", + GoVersion: runtime.Version(), + Compiler: runtime.Compiler, + Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), + } +) // Capabilities describes the capabilities of the Kubernetes cluster that Tiller is attached to. type Capabilities struct { diff --git a/pkg/lint/rules/template.go b/pkg/lint/rules/template.go index 3ccd9acdb..9343a3a84 100644 --- a/pkg/lint/rules/template.go +++ b/pkg/lint/rules/template.go @@ -21,10 +21,8 @@ import ( "fmt" "os" "path/filepath" - "runtime" "github.com/ghodss/yaml" - "k8s.io/apimachinery/pkg/version" "k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/engine" "k8s.io/helm/pkg/lint/support" @@ -55,14 +53,8 @@ func Templates(linter *support.Linter) { options := chartutil.ReleaseOptions{Name: "testRelease", Time: timeconv.Now(), Namespace: "testNamespace"} caps := &chartutil.Capabilities{ - APIVersions: chartutil.DefaultVersionSet, - KubeVersion: &version.Info{ - Major: "1", - Minor: "7", - GoVersion: runtime.Version(), - Compiler: runtime.Compiler, - Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), - }, + APIVersions: chartutil.DefaultVersionSet, + KubeVersion: chartutil.DefaultKubeVersion, TillerVersion: tversion.GetVersionProto(), } valuesToRender, err := chartutil.ToRenderValuesCaps(chart, chart.Values, options, caps)