Skip to content

Commit c3a5f27

Browse files
Add --take-ownership flag for install and upgrade commands
The `TakeOwnership` setting was added to the install and upgrade actions in #12876 This PR allows setting this option on install and upgrade via the CLI using a --take-ownership flag Signed-off-by: Mayank Shah <[email protected]>
1 parent dd35343 commit c3a5f27

6 files changed

+27
-0
lines changed

cmd/helm/install.go

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

cmd/helm/install_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ func TestInstall(t *testing.T) {
102102
cmd: "install aeneas testdata/testcharts/empty --replace",
103103
golden: "output/install-and-replace.txt",
104104
},
105+
// Install, take ownership
106+
{
107+
name: "install and replace release",
108+
cmd: "install aeneas-take-ownership testdata/testcharts/empty --take-ownership",
109+
golden: "output/install-and-take-ownership.txt",
110+
},
105111
// Install, with timeout
106112
{
107113
name: "install with a timeout",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
NAME: aeneas-take-ownership
2+
LAST DEPLOYED: Fri Sep 2 22:04:05 1977
3+
NAMESPACE: default
4+
STATUS: deployed
5+
REVISION: 1
6+
TEST SUITE: None
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Release "funny-bunny" has been upgraded. Happy Helming!
2+
NAME: funny-bunny
3+
LAST DEPLOYED: Fri Sep 2 22:04:05 1977
4+
NAMESPACE: default
5+
STATUS: deployed
6+
REVISION: 3
7+
TEST SUITE: None

cmd/helm/upgrade.go

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

cmd/helm/upgrade_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ func TestUpgradeCmd(t *testing.T) {
114114
golden: "output/upgrade-with-reset-values2.txt",
115115
rels: []*release.Release{relMock("funny-bunny", 5, ch2)},
116116
},
117+
{
118+
name: "upgrade a release with --take-ownership",
119+
cmd: fmt.Sprintf("upgrade funny-bunny '%s' --take-ownership", chartPath),
120+
golden: "output/upgrade-and-take-ownership.txt",
121+
rels: []*release.Release{relMock("funny-bunny", 2, ch)},
122+
},
117123
{
118124
name: "install a release with 'upgrade --install'",
119125
cmd: fmt.Sprintf("upgrade zany-bunny -i '%s'", chartPath),

0 commit comments

Comments
 (0)