From d863d9a886c187cee2a5b606d146e8c0ea26a0e5 Mon Sep 17 00:00:00 2001
From: Matt Butcher <technosophos@gmail.com>
Date: Tue, 16 May 2017 16:33:43 -0600
Subject: [PATCH] fix(lint): add KubeVersion and TillerVersion to linter

Closes #2393
---
 pkg/lint/rules/template.go                        | 15 ++++++++++++++-
 .../rules/testdata/albatross/templates/svc.yaml   |  2 ++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/pkg/lint/rules/template.go b/pkg/lint/rules/template.go
index 5b98d4886..73206b80c 100644
--- a/pkg/lint/rules/template.go
+++ b/pkg/lint/rules/template.go
@@ -21,12 +21,15 @@ 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"
 	"k8s.io/helm/pkg/timeconv"
+	tversion "k8s.io/helm/pkg/version"
 )
 
 // Templates lints the templates in the Linter.
@@ -51,7 +54,17 @@ func Templates(linter *support.Linter) {
 	}
 
 	options := chartutil.ReleaseOptions{Name: "testRelease", Time: timeconv.Now(), Namespace: "testNamespace"}
-	caps := &chartutil.Capabilities{APIVersions: chartutil.DefaultVersionSet}
+	caps := &chartutil.Capabilities{
+		APIVersions: chartutil.DefaultVersionSet,
+		KubeVersion: &version.Info{
+			Major:     "1",
+			Minor:     "6",
+			GoVersion: runtime.Version(),
+			Compiler:  runtime.Compiler,
+			Platform:  fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
+		},
+		TillerVersion: tversion.GetVersionProto(),
+	}
 	valuesToRender, err := chartutil.ToRenderValuesCaps(chart, chart.Values, options, caps)
 	if err != nil {
 		// FIXME: This seems to generate a duplicate, but I can't find where the first
diff --git a/pkg/lint/rules/testdata/albatross/templates/svc.yaml b/pkg/lint/rules/testdata/albatross/templates/svc.yaml
index 2c44ea2c6..167148112 100644
--- a/pkg/lint/rules/testdata/albatross/templates/svc.yaml
+++ b/pkg/lint/rules/testdata/albatross/templates/svc.yaml
@@ -8,6 +8,8 @@ metadata:
     heritage: {{ .Release.Service | quote }}
     release: {{ .Release.Name | quote }}
     chart: "{{.Chart.Name}}-{{.Chart.Version}}"
+    kubeVersion: {{ .Capabilities.KubeVersion.Major }}
+    tillerVersion: {{ .Capabilities.TillerVersion }}
 spec:
   ports:
   - port: {{default 80 .Values.httpPort | quote}}
-- 
GitLab