Repository: helm/helm
Pull request #6889 (2019-11-05 23:48:00)

fix(cmd): Add message about deprecated chart
Partial #3724

bacongobbler: Hi @kvendingoldo. Thanks for the PR.

Because we're in the final release candidate stages before we release 3.0.0, we are only looking at major regressions or bug fixes fixes. Since this is a new feature, we will take a closer look at this feature for Helm 3.1.0 - after 3.0.0 has been released. Just letting you know that it'll take a while before we get around to reviewing this. Thanks!
kvendingoldo: @hickeyma I fixed your comments.

Patch:
diff --git a/cmd/helm/install.go b/cmd/helm/install.go
index 176250f84..b75dfce74 100644
--- a/cmd/helm/install.go
+++ b/cmd/helm/install.go
@@ -17,6 +17,7 @@ limitations under the License.
 package main
 
 import (
+	"fmt"
 	"io"
 	"time"
 
@@ -182,6 +183,10 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options
 		return nil, err
 	}
 
+	if chartRequested.Metadata.Deprecated {
+		fmt.Fprintln(out, "WARNING: This chart is deprecated")
+	}
+
 	if req := chartRequested.Metadata.Dependencies; req != nil {
 		// If CheckDependencies returns an error, we have unfulfilled dependencies.
 		// As of Helm 2.4.0, this is treated as a stopping condition:
diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go
index dce8ad74f..acfc23198 100644
--- a/cmd/helm/upgrade.go
+++ b/cmd/helm/upgrade.go
@@ -127,6 +127,10 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
 				}
 			}
 
+			if ch.Metadata.Deprecated {
+				fmt.Fprintln(out, "WARNING: This chart is deprecated")
+			}
+
 			rel, err := client.Run(args[0], ch, vals)
 			if err != nil {
 				return errors.Wrap(err, "UPGRADE FAILED")


Test patch:
diff --git a/cmd/helm/install_test.go b/cmd/helm/install_test.go
index 9ab25417b..e8b573dfc 100644
--- a/cmd/helm/install_test.go
+++ b/cmd/helm/install_test.go
@@ -183,6 +183,12 @@ func TestInstall(t *testing.T) {
 			wantError: true,
 			golden:    "output/subchart-schema-cli-negative.txt",
 		},
+		// Install deprecated chart
+		{
+			name:   "install with warning about deprecated chart",
+			cmd:    "install aeneas testdata/testcharts/deprecated --namespace default",
+			golden: "output/deprecated-chart.txt",
+		},
 	}
 
 	runTestActionCmd(t, tests)
diff --git a/cmd/helm/testdata/output/deprecated-chart.txt b/cmd/helm/testdata/output/deprecated-chart.txt
new file mode 100644
index 000000000..e5be2c3f1
--- /dev/null
+++ b/cmd/helm/testdata/output/deprecated-chart.txt
@@ -0,0 +1,7 @@
+WARNING: This chart is deprecated
+NAME: aeneas
+LAST DEPLOYED: Fri Sep  2 22:04:05 1977
+NAMESPACE: default
+STATUS: deployed
+REVISION: 1
+TEST SUITE: None
diff --git a/cmd/helm/testdata/testcharts/deprecated/Chart.yaml b/cmd/helm/testdata/testcharts/deprecated/Chart.yaml
new file mode 100644
index 000000000..10185beeb
--- /dev/null
+++ b/cmd/helm/testdata/testcharts/deprecated/Chart.yaml
@@ -0,0 +1,8 @@
+apiVersion: v1
+description: Deprecated testing chart
+home: https://helm.sh/helm
+name: deprecated
+sources:
+  - https://github.com/helm/helm
+version: 0.1.0
+deprecated: true
diff --git a/cmd/helm/testdata/testcharts/deprecated/README.md b/cmd/helm/testdata/testcharts/deprecated/README.md
new file mode 100644
index 000000000..0df9a8bbc
--- /dev/null
+++ b/cmd/helm/testdata/testcharts/deprecated/README.md
@@ -0,0 +1,3 @@
+#Deprecated
+
+This space intentionally left blank.