Repository: helm/helm
Pull request #8562 (2020-08-05 17:14:10)

Update Common Lables template in starter chart
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. Make sure to read the Contributing Guide before submitting your PR: https://github.com/helm/helm/blob/master/CONTRIBUTING.md
2. If this PR closes another issue, add 'closes #<issue number>' somewhere in the PR summary. GitHub will automatically close that issue when this PR gets merged. Alternatively, adding 'refs #<issue number>' will not close the issue, but help provide the reviewer more context.-->

**What this PR does / why we need it**:
Have update the Common Labels template in the starter chart so that the value for the `app.kubernetes.io/version` is set to the same value as the image tag used in the deployment.

**Special notes for your reviewer**:

**If applicable**:
- [ ] this PR contains documentation
- [ ] this PR contains unit tests
- [ ] this PR has been tested for backwards compatibility



Patch:
diff --git a/README.md b/README.md
index 9c39175bc..bb6908fdb 100644
--- a/README.md
+++ b/README.md
@@ -43,7 +43,7 @@ If you want to use a package manager:
 - [GoFish](https://gofi.sh/) users can use `gofish install helm`.
 - [Snapcraft](https://snapcraft.io/) users can use `snap install helm --classic`
 
-To rapidly get Helm up and running, start with the [Quick Start Guide](https://helm.sh/docs/intro/quickstart/).
+To rapidly get Helm up and running, start with the [Quick Start Guide](https://docs.helm.sh/using_helm/#quickstart-guide).
 
 See the [installation guide](https://helm.sh/docs/intro/install/) for more options,
 including installing pre-releases.
diff --git a/cmd/helm/show.go b/cmd/helm/show.go
index fe5eaee26..c122d8476 100644
--- a/cmd/helm/show.go
+++ b/cmd/helm/show.go
@@ -151,9 +151,6 @@ func addShowFlags(subCmd *cobra.Command, client *action.Show) {
 	f := subCmd.Flags()
 
 	f.BoolVar(&client.Devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored")
-	if subCmd.Name() == "values" {
-		f.StringVar(&client.JSONPathTemplate, "jsonpath", "", "supply a JSONPath expression to filter the output")
-	}
 	addChartPathOptionsFlags(f, &client.ChartPathOptions)
 
 	err := subCmd.RegisterFlagCompletionFunc("version", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
diff --git a/pkg/action/show.go b/pkg/action/show.go
index 4eab2b4fd..9baa9cf43 100644
--- a/pkg/action/show.go
+++ b/pkg/action/show.go
@@ -20,8 +20,6 @@ import (
 	"fmt"
 	"strings"
 
-	"github.com/pkg/errors"
-	"k8s.io/cli-runtime/pkg/printers"
 	"sigs.k8s.io/yaml"
 
 	"helm.sh/helm/v3/pkg/chart"
@@ -54,10 +52,9 @@ func (o ShowOutputFormat) String() string {
 // It provides the implementation of 'helm show' and its respective subcommands.
 type Show struct {
 	ChartPathOptions
-	Devel            bool
-	OutputFormat     ShowOutputFormat
-	JSONPathTemplate string
-	chart            *chart.Chart // for testing
+	Devel        bool
+	OutputFormat ShowOutputFormat
+	chart        *chart.Chart // for testing
 }
 
 // NewShow creates a new Show object with the given configuration.
@@ -90,17 +87,9 @@ func (s *Show) Run(chartpath string) (string, error) {
 		if s.OutputFormat == ShowAll {
 			fmt.Fprintln(&out, "---")
 		}
-		if s.JSONPathTemplate != "" {
-			printer, err := printers.NewJSONPathPrinter(s.JSONPathTemplate)
-			if err != nil {
-				return "", errors.Wrapf(err, "error parsing jsonpath %s", s.JSONPathTemplate)
-			}
-			printer.Execute(&out, s.chart.Values)
-		} else {
-			for _, f := range s.chart.Raw {
-				if f.Name == chartutil.ValuesfileName {
-					fmt.Fprintln(&out, string(f.Data))
-				}
+		for _, f := range s.chart.Raw {
+			if f.Name == chartutil.ValuesfileName {
+				fmt.Fprintln(&out, string(f.Data))
 			}
 		}
 	}
diff --git a/pkg/chartutil/create.go b/pkg/chartutil/create.go
index 6e382b961..cf10f0875 100644
--- a/pkg/chartutil/create.go
+++ b/pkg/chartutil/create.go
@@ -381,9 +381,8 @@ const defaultNotes = `1. Get the application URL by running these commands:
   echo http://$SERVICE_IP:{{ .Values.service.port }}
 {{- else if contains "ClusterIP" .Values.service.type }}
   export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "<CHARTNAME>.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
-  export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
   echo "Visit http://127.0.0.1:8080 to use your application"
-  kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
+  kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
 {{- end }}
 `
 
@@ -425,9 +424,7 @@ Common labels
 {{- define "<CHARTNAME>.labels" -}}
 helm.sh/chart: {{ include "<CHARTNAME>.chart" . }}
 {{ include "<CHARTNAME>.selectorLabels" . }}
-{{- if .Chart.AppVersion }}
-app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
-{{- end }}
+app.kubernetes.io/version: {{ .Values.image.tag | default .Chart.AppVersion | quote }}
 app.kubernetes.io/managed-by: {{ .Release.Service }}
 {{- end }}
 


Test patch:
diff --git a/pkg/action/show_test.go b/pkg/action/show_test.go
index a2efdc8ac..7be9daaa5 100644
--- a/pkg/action/show_test.go
+++ b/pkg/action/show_test.go
@@ -69,17 +69,3 @@ func TestShowNoValues(t *testing.T) {
 		t.Errorf("expected empty values buffer, got %s", output)
 	}
 }
-
-func TestShowValuesByJsonPathFormat(t *testing.T) {
-	client := NewShow(ShowValues)
-	client.JSONPathTemplate = "{$.nestedKey.simpleKey}"
-	client.chart = buildChart(withSampleValues())
-	output, err := client.Run("")
-	if err != nil {
-		t.Fatal(err)
-	}
-	expect := "simpleValue"
-	if output != expect {
-		t.Errorf("Expected\n%q\nGot\n%q\n", expect, output)
-	}
-}