Repository: helm/helm
Pull request #7830 (2020-03-26 17:22:29)

Render subchart notes on upgrade install
I noticed that subchart notes weren't rendered when using `upgrade --install`.  This PR includes the fix and a test for it.


Patch:
diff --git a/README.md b/README.md
index bb6908fdb..745a60c2b 100644
--- a/README.md
+++ b/README.md
@@ -41,7 +41,6 @@ If you want to use a package manager:
 - [Chocolatey](https://chocolatey.org/) users can use `choco install kubernetes-helm`.
 - [Scoop](https://scoop.sh/) users can use `scoop install helm`.
 - [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://docs.helm.sh/using_helm/#quickstart-guide).
 
diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go
index af8ff68e3..48eac0b0f 100644
--- a/cmd/helm/upgrade.go
+++ b/cmd/helm/upgrade.go
@@ -112,6 +112,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
 					instClient.Atomic = client.Atomic
 					instClient.PostRenderer = client.PostRenderer
 					instClient.DisableOpenAPIValidation = client.DisableOpenAPIValidation
+					instClient.SubNotes = client.SubNotes
 
 					rel, err := runInstall(args, instClient, valueOpts, out)
 					if err != nil {


Test patch:
diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-notes/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-subchart-notes/Chart.yaml
new file mode 100644
index 000000000..90545a6a3
--- /dev/null
+++ b/cmd/helm/testdata/testcharts/chart-with-subchart-notes/Chart.yaml
@@ -0,0 +1,7 @@
+apiVersion: v2
+description: Chart with subchart notes
+name: chart-with-subchart-notes
+version: 0.0.1
+dependencies:
+  - name: subchart-with-notes
+    version: 0.0.1
diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/Chart.yaml
new file mode 100644
index 000000000..f0fead9ee
--- /dev/null
+++ b/cmd/helm/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/Chart.yaml
@@ -0,0 +1,4 @@
+apiVersion: v2
+description: Subchart with notes
+name: subchart-with-notes
+version: 0.0.1
diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/templates/NOTES.txt b/cmd/helm/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/templates/NOTES.txt
new file mode 100644
index 000000000..1f61a294e
--- /dev/null
+++ b/cmd/helm/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/templates/NOTES.txt
@@ -0,0 +1,1 @@
+SUBCHART NOTES
diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-notes/templates/NOTES.txt b/cmd/helm/testdata/testcharts/chart-with-subchart-notes/templates/NOTES.txt
new file mode 100644
index 000000000..9e166d370
--- /dev/null
+++ b/cmd/helm/testdata/testcharts/chart-with-subchart-notes/templates/NOTES.txt
@@ -0,0 +1,1 @@
+PARENT NOTES
diff --git a/cmd/helm/upgrade_test.go b/cmd/helm/upgrade_test.go
index 3cecbe6d3..4956c0247 100644
--- a/cmd/helm/upgrade_test.go
+++ b/cmd/helm/upgrade_test.go
@@ -196,6 +196,38 @@ func TestUpgradeWithStringValue(t *testing.T) {
 
 }
 
+func TestUpgradeInstallWithSubchartNotes(t *testing.T) {
+
+	releaseName := "wacky-bunny-v1"
+	relMock, ch, _ := prepareMockRelease(releaseName, t)
+
+	defer resetEnv()()
+
+	store := storageFixture()
+
+	store.Create(relMock(releaseName, 1, ch))
+
+	cmd := fmt.Sprintf("upgrade %s -i --render-subchart-notes '%s'", releaseName, "testdata/testcharts/chart-with-subchart-notes")
+	_, _, err := executeActionCommandC(store, cmd)
+	if err != nil {
+		t.Errorf("unexpected error, got '%v'", err)
+	}
+
+	upgradedRel, err := store.Get(releaseName, 2)
+	if err != nil {
+		t.Errorf("unexpected error, got '%v'", err)
+	}
+
+	if !strings.Contains(upgradedRel.Info.Notes, "PARENT NOTES") {
+		t.Errorf("The parent notes are not set correctly. NOTES: %s", upgradedRel.Info.Notes)
+	}
+
+	if !strings.Contains(upgradedRel.Info.Notes, "SUBCHART NOTES") {
+		t.Errorf("The subchart notes are not set correctly. NOTES: %s", upgradedRel.Info.Notes)
+	}
+
+}
+
 func TestUpgradeWithValuesFile(t *testing.T) {
 
 	releaseName := "funny-bunny-v4"