Repository: helm/helm (go)

Issue:
helm .Capabilities.KubeVersion giving unexpected results
Not sure if anyone faced the same issue before, While getting the kube version in helm chart using `{{ .Capabilities.KubeVersion.Minor }}` , It's not resolving it correctly. Always output value as 16.

As per my kube server version, i am expecting it to resolve as 18.

Output of `helm version`:
version.BuildInfo{Version:"v3.2.1", GitCommit:"fe51cd1e31e6a202cba7dead9552a6d418ded79a", GitTreeState:"clean", GoVersion:"go1.13.10"}

Can someone point me in the right direction here on what's missing.
Please let me know if you need any more info.

Output of `kubectl version`:
Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.10", GitCommit:"37d169313237cb4ceb2cc4bef300f2ae3053c1a2", GitTreeState:"clean", BuildDate:"2019-08-19T10:52:43Z", GoVersion:"go1.11.13", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.1", GitCommit:"7879fc12a63337efff607952a323df90cdc7a335", GitTreeState:"clean", BuildDate:"2020-04-08T17:30:47Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}

Cloud Provider/Platform (AKS, GKE, Minikube etc.): AWS cloud
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"




Pull request:
bump DefaultCapabilities to 1.18
This bumps the mocked kube version to match what is in go.mod.

closes #8113.

Patch:
diff --git a/pkg/chartutil/capabilities.go b/pkg/chartutil/capabilities.go
index f46350bb1..ce968c5d7 100644
--- a/pkg/chartutil/capabilities.go
+++ b/pkg/chartutil/capabilities.go
@@ -29,9 +29,9 @@ var (
 	// DefaultCapabilities is the default set of capabilities.
 	DefaultCapabilities = &Capabilities{
 		KubeVersion: KubeVersion{
-			Version: "v1.16.0",
+			Version: "v1.18.0",
 			Major:   "1",
-			Minor:   "16",
+			Minor:   "18",
 		},
 		APIVersions: DefaultVersionSet,
 	}


Test patch:
diff --git a/cmd/helm/testdata/output/template-name-template.txt b/cmd/helm/testdata/output/template-name-template.txt
index 0130a2a92..24f2bb616 100644
--- a/cmd/helm/testdata/output/template-name-template.txt
+++ b/cmd/helm/testdata/output/template-name-template.txt
@@ -71,8 +71,8 @@ metadata:
     helm.sh/chart: "subchart1-0.1.0"
     app.kubernetes.io/instance: "foobar-YWJj-baz"
     kube-version/major: "1"
-    kube-version/minor: "16"
-    kube-version/version: "v1.16.0"
+    kube-version/minor: "18"
+    kube-version/version: "v1.18.0"
 spec:
   type: ClusterIP
   ports:
diff --git a/cmd/helm/testdata/output/template-set.txt b/cmd/helm/testdata/output/template-set.txt
index ddaa8886b..4c7f1f626 100644
--- a/cmd/helm/testdata/output/template-set.txt
+++ b/cmd/helm/testdata/output/template-set.txt
@@ -71,8 +71,8 @@ metadata:
     helm.sh/chart: "subchart1-0.1.0"
     app.kubernetes.io/instance: "RELEASE-NAME"
     kube-version/major: "1"
-    kube-version/minor: "16"
-    kube-version/version: "v1.16.0"
+    kube-version/minor: "18"
+    kube-version/version: "v1.18.0"
 spec:
   type: ClusterIP
   ports:
diff --git a/cmd/helm/testdata/output/template-show-only-multiple.txt b/cmd/helm/testdata/output/template-show-only-multiple.txt
index abb9a2e10..75b590e20 100644
--- a/cmd/helm/testdata/output/template-show-only-multiple.txt
+++ b/cmd/helm/testdata/output/template-show-only-multiple.txt
@@ -8,8 +8,8 @@ metadata:
     helm.sh/chart: "subchart1-0.1.0"
     app.kubernetes.io/instance: "RELEASE-NAME"
     kube-version/major: "1"
-    kube-version/minor: "16"
-    kube-version/version: "v1.16.0"
+    kube-version/minor: "18"
+    kube-version/version: "v1.18.0"
     kube-api-version/test: v1
 spec:
   type: ClusterIP
diff --git a/cmd/helm/testdata/output/template-show-only-one.txt b/cmd/helm/testdata/output/template-show-only-one.txt
index f0dd0834e..ce61f481f 100644
--- a/cmd/helm/testdata/output/template-show-only-one.txt
+++ b/cmd/helm/testdata/output/template-show-only-one.txt
@@ -8,8 +8,8 @@ metadata:
     helm.sh/chart: "subchart1-0.1.0"
     app.kubernetes.io/instance: "RELEASE-NAME"
     kube-version/major: "1"
-    kube-version/minor: "16"
-    kube-version/version: "v1.16.0"
+    kube-version/minor: "18"
+    kube-version/version: "v1.18.0"
     kube-api-version/test: v1
 spec:
   type: ClusterIP
diff --git a/cmd/helm/testdata/output/template-values-files.txt b/cmd/helm/testdata/output/template-values-files.txt
index ddaa8886b..4c7f1f626 100644
--- a/cmd/helm/testdata/output/template-values-files.txt
+++ b/cmd/helm/testdata/output/template-values-files.txt
@@ -71,8 +71,8 @@ metadata:
     helm.sh/chart: "subchart1-0.1.0"
     app.kubernetes.io/instance: "RELEASE-NAME"
     kube-version/major: "1"
-    kube-version/minor: "16"
-    kube-version/version: "v1.16.0"
+    kube-version/minor: "18"
+    kube-version/version: "v1.18.0"
 spec:
   type: ClusterIP
   ports:
diff --git a/cmd/helm/testdata/output/template-with-api-version.txt b/cmd/helm/testdata/output/template-with-api-version.txt
index 7a2a4d5bf..210dcc503 100644
--- a/cmd/helm/testdata/output/template-with-api-version.txt
+++ b/cmd/helm/testdata/output/template-with-api-version.txt
@@ -71,8 +71,8 @@ metadata:
     helm.sh/chart: "subchart1-0.1.0"
     app.kubernetes.io/instance: "RELEASE-NAME"
     kube-version/major: "1"
-    kube-version/minor: "16"
-    kube-version/version: "v1.16.0"
+    kube-version/minor: "18"
+    kube-version/version: "v1.18.0"
     kube-api-version/test: v1
 spec:
   type: ClusterIP
diff --git a/cmd/helm/testdata/output/template-with-crds.txt b/cmd/helm/testdata/output/template-with-crds.txt
index b04a4d5d2..289eec291 100644
--- a/cmd/helm/testdata/output/template-with-crds.txt
+++ b/cmd/helm/testdata/output/template-with-crds.txt
@@ -87,8 +87,8 @@ metadata:
     helm.sh/chart: "subchart1-0.1.0"
     app.kubernetes.io/instance: "RELEASE-NAME"
     kube-version/major: "1"
-    kube-version/minor: "16"
-    kube-version/version: "v1.16.0"
+    kube-version/minor: "18"
+    kube-version/version: "v1.18.0"
     kube-api-version/test: v1
 spec:
   type: ClusterIP
diff --git a/cmd/helm/testdata/output/template.txt b/cmd/helm/testdata/output/template.txt
index 8301c2231..82a21c5a1 100644
--- a/cmd/helm/testdata/output/template.txt
+++ b/cmd/helm/testdata/output/template.txt
@@ -71,8 +71,8 @@ metadata:
     helm.sh/chart: "subchart1-0.1.0"
     app.kubernetes.io/instance: "RELEASE-NAME"
     kube-version/major: "1"
-    kube-version/minor: "16"
-    kube-version/version: "v1.16.0"
+    kube-version/minor: "18"
+    kube-version/version: "v1.18.0"
 spec:
   type: ClusterIP
   ports:
diff --git a/pkg/chartutil/capabilities_test.go b/pkg/chartutil/capabilities_test.go
index 3eeac76e2..416eea06d 100644
--- a/pkg/chartutil/capabilities_test.go
+++ b/pkg/chartutil/capabilities_test.go
@@ -42,19 +42,19 @@ func TestDefaultVersionSet(t *testing.T) {
 
 func TestDefaultCapabilities(t *testing.T) {
 	kv := DefaultCapabilities.KubeVersion
-	if kv.String() != "v1.16.0" {
-		t.Errorf("Expected default KubeVersion.String() to be v1.16.0, got %q", kv.String())
+	if kv.String() != "v1.18.0" {
+		t.Errorf("Expected default KubeVersion.String() to be v1.18.0, got %q", kv.String())
 	}
-	if kv.Version != "v1.16.0" {
-		t.Errorf("Expected default KubeVersion.Version to be v1.16.0, got %q", kv.Version)
+	if kv.Version != "v1.18.0" {
+		t.Errorf("Expected default KubeVersion.Version to be v1.18.0, got %q", kv.Version)
 	}
-	if kv.GitVersion() != "v1.16.0" {
-		t.Errorf("Expected default KubeVersion.GitVersion() to be v1.16.0, got %q", kv.Version)
+	if kv.GitVersion() != "v1.18.0" {
+		t.Errorf("Expected default KubeVersion.GitVersion() to be v1.18.0, got %q", kv.Version)
 	}
 	if kv.Major != "1" {
 		t.Errorf("Expected default KubeVersion.Major to be 1, got %q", kv.Major)
 	}
-	if kv.Minor != "16" {
+	if kv.Minor != "18" {
 		t.Errorf("Expected default KubeVersion.Minor to be 16, got %q", kv.Minor)
 	}
 }