Add --take-ownership flag for install and upgrade commands

The `TakeOwnership` setting was added to the install and upgrade actions in
https://github.com/helm/helm/pull/12876

This PR allows setting this option on install and upgrade via the CLI
using a --take-ownership flag

Signed-off-by: Mayank Shah <mayankshah1614@gmail.com>
pull/13538/head
Mayank Shah 10 months ago committed by Payal Godhani
parent ea67fc93bc
commit 197bfe9f64

@ -206,6 +206,7 @@ func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Instal
f.StringToStringVarP(&client.Labels, "labels", "l", nil, "Labels that would be added to release metadata. Should be divided by comma.")
f.BoolVar(&client.EnableDNS, "enable-dns", false, "enable DNS lookups when rendering templates")
f.BoolVar(&client.HideNotes, "hide-notes", false, "if set, do not show notes in install output. Does not affect presence in chart metadata")
f.BoolVar(&client.TakeOwnership, "take-ownership", false, "if set, install will ignore the check for helm annotations and take ownership of the existing resources.")
addValueOptionsFlags(f, valueOpts)
addChartPathOptionsFlags(f, &client.ChartPathOptions)

@ -102,6 +102,12 @@ func TestInstall(t *testing.T) {
cmd: "install aeneas testdata/testcharts/empty --replace",
golden: "output/install-and-replace.txt",
},
// Install, take ownership
{
name: "install and replace release",
cmd: "install aeneas-take-ownership testdata/testcharts/empty --take-ownership",
golden: "output/install-and-take-ownership.txt",
},
// Install, with timeout
{
name: "install with a timeout",

@ -0,0 +1,6 @@
NAME: aeneas-take-ownership
LAST DEPLOYED: Fri Sep 2 22:04:05 1977
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None

@ -0,0 +1,7 @@
Release "funny-bunny" has been upgraded. Happy Helming!
NAME: funny-bunny
LAST DEPLOYED: Fri Sep 2 22:04:05 1977
NAMESPACE: default
STATUS: deployed
REVISION: 3
TEST SUITE: None

@ -289,6 +289,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
f.StringVar(&client.Description, "description", "", "add a custom description")
f.BoolVar(&client.DependencyUpdate, "dependency-update", false, "update dependencies if they are missing before installing the chart")
f.BoolVar(&client.EnableDNS, "enable-dns", false, "enable DNS lookups when rendering templates")
f.BoolVar(&client.TakeOwnership, "take-ownership", false, "if set, upgrade will ignore the check for helm annotations and take ownership of the existing resources.")
addChartPathOptionsFlags(f, &client.ChartPathOptions)
addValueOptionsFlags(f, valueOpts)
bindOutputFlag(cmd, &outfmt)

@ -114,6 +114,12 @@ func TestUpgradeCmd(t *testing.T) {
golden: "output/upgrade-with-reset-values2.txt",
rels: []*release.Release{relMock("funny-bunny", 5, ch2)},
},
{
name: "upgrade a release with --take-ownership",
cmd: fmt.Sprintf("upgrade funny-bunny '%s' --take-ownership", chartPath),
golden: "output/upgrade-and-take-ownership.txt",
rels: []*release.Release{relMock("funny-bunny", 2, ch)},
},
{
name: "install a release with 'upgrade --install'",
cmd: fmt.Sprintf("upgrade zany-bunny -i '%s'", chartPath),

Loading…
Cancel
Save