From fed7efd4d769a31d9460e115ac608a37f6da8461 Mon Sep 17 00:00:00 2001 From: Daishan Date: Wed, 2 Jun 2021 16:08:48 -0700 Subject: [PATCH] Add forceAdopt flag (cherry picked from commit 92c390350726b8f2f7de3d0b5aa643ae7a821099) --- cmd/helm/install.go | 1 + cmd/helm/upgrade.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 23ff29d95..08cc99df6 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -201,6 +201,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.ForceAdopt, "force-adopt", false, "force adopt resources that were created outside helm") addValueOptionsFlags(f, valueOpts) addChartPathOptionsFlags(f, &client.ChartPathOptions) diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index 108550cbf..0edd84ee3 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -128,6 +128,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { fmt.Fprintf(out, "Release %q does not exist. Installing it now.\n", args[0]) } instClient := action.NewInstall(cfg) + instClient.ForceAdopt = client.Adopt instClient.CreateNamespace = createNamespace instClient.ChartPathOptions = client.ChartPathOptions instClient.Force = client.Force @@ -280,6 +281,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.Adopt, "force-adopt", false, "force adopt resources that were created outside helm") addChartPathOptionsFlags(f, &client.ChartPathOptions) addValueOptionsFlags(f, valueOpts) bindOutputFlag(cmd, &outfmt)