Merge pull request #8310 from stantonxu/dev-v2

Add Warning when installing or upgrading a deprecated chart - replacing PR #8262
pull/8390/head
Martin Hickey 4 years ago committed by GitHub
commit 0499fb5987
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -267,6 +267,10 @@ func (i *installCmd) run() error {
return prettyError(err)
}
if chartRequested.Metadata.Deprecated {
fmt.Fprintln(os.Stderr, "WARNING: This chart is deprecated")
}
if req, err := chartutil.LoadRequirements(chartRequested); err == nil {
// If checkDependencies returns an error, we have unfulfilled dependencies.
// As of Helm 2.4.0, this is treated as a stopping condition:

@ -207,6 +207,14 @@ func TestInstall(t *testing.T) {
resp: helm.ReleaseMock(&helm.MockReleaseOptions{Name: "virgil"}),
expected: "info:\n Description: Release mock\n first_deployed:\n seconds: 242085845\n last_deployed:\n seconds: 242085845\n status:\n code: 1\nname: virgil\nnamespace: default\n",
},
// Install deprecated chart
{
name: "install with warning about deprecated chart",
args: []string{"testdata/testcharts/deprecatedchart"},
flags: []string{"--name", "deprecatedchart"},
resp: helm.ReleaseMock(&helm.MockReleaseOptions{Name: "deprecatedchart"}),
expected: "deprecatedchart",
},
}
runReleaseCases(t, tests, func(c *helm.FakeClient, out io.Writer) *cobra.Command {

@ -0,0 +1,8 @@
apiVersion: v1
description: Deprecated testing chart
home: https://helm.sh/helm
name: deprecatedchart
sources:
- https://github.com/helm/helm
version: 0.1.0
deprecated: true

@ -0,0 +1,3 @@
#Deprecated
This space intentionally left blank.

@ -19,6 +19,7 @@ package main
import (
"fmt"
"io"
"os"
"strings"
"github.com/spf13/cobra"
@ -266,6 +267,10 @@ func (u *upgradeCmd) run() error {
return prettyError(err)
}
if ch.Metadata.Deprecated {
fmt.Fprintln(os.Stderr, "WARNING: This chart is deprecated")
}
resp, err := u.client.UpdateReleaseFromChart(
u.release,
ch,

@ -85,6 +85,7 @@ func TestUpgradeCmd(t *testing.T) {
originalDepsPath := filepath.Join("testdata/testcharts/reqtest")
missingDepsPath := filepath.Join("testdata/testcharts/chart-missing-deps")
badDepsPath := filepath.Join("testdata/testcharts/chart-bad-requirements")
deprecatedChart := filepath.Join("testdata/testcharts/deprecatedchart")
var ch3 *chart.Chart
ch3, err = chartutil.Load(originalDepsPath)
if err != nil {
@ -183,6 +184,13 @@ func TestUpgradeCmd(t *testing.T) {
resp: helm.ReleaseMock(&helm.MockReleaseOptions{Name: "bonkers-bunny", Version: 1, Chart: ch3}),
err: true,
},
{
name: "upgrade a release with deprecated chart",
args: []string{"crazy-bunny", deprecatedChart},
resp: helm.ReleaseMock(&helm.MockReleaseOptions{Name: "crazy-bunny", Version: 2, Chart: ch}),
expected: "Release \"crazy-bunny\" has been upgraded.\n",
rels: []*release.Release{helm.ReleaseMock(&helm.MockReleaseOptions{Name: "crazy-bunny", Version: 2, Chart: ch})},
},
}
cmd := func(c *helm.FakeClient, out io.Writer) *cobra.Command {

Loading…
Cancel
Save