Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func renderManifests(cfg *helmaction.Configuration, hr *v2.HelmRelease, chartDir
}

// upgradeRelease runs a Helm upgrade (installing if necessary).
func upgradeRelease(cfg *helmaction.Configuration, hr *v2.HelmRelease, chartDir string, vals map[string]interface{}) error {
func upgradeRelease(cfg *helmaction.Configuration, hr *v2.HelmRelease, chartDir string, vals map[string]interface{}, takeOwnership bool) error {
relName := hr.Name
namespace := hr.Namespace

Expand All @@ -315,6 +315,7 @@ func upgradeRelease(cfg *helmaction.Configuration, hr *v2.HelmRelease, chartDir
inst := helmaction.NewInstall(cfg)
inst.Namespace = namespace
inst.ReleaseName = relName
inst.TakeOwnership = takeOwnership
if !plain {
inst.PostRenderer = &fluxPostRenderer{name: relName, ns: namespace}
}
Expand All @@ -325,6 +326,7 @@ func upgradeRelease(cfg *helmaction.Configuration, hr *v2.HelmRelease, chartDir
up := helmaction.NewUpgrade(cfg)
up.Namespace = namespace
up.Install = true // informative only
up.TakeOwnership = takeOwnership
if !plain {
up.PostRenderer = &fluxPostRenderer{name: relName, ns: namespace}
}
Expand Down Expand Up @@ -522,6 +524,7 @@ func cmdShow() *cobra.Command {
// cmdApply returns the `cozypkg apply` command.
func cmdApply() *cobra.Command {
var autoResume bool
var takeOwnership bool
cmd := cmdFactory("apply", func(cfg *helmaction.Configuration, hr *v2.HelmRelease, chartDir string) error {
if plain && autoResume {
return fmt.Errorf("--resume may not be used with --plain")
Expand Down Expand Up @@ -571,7 +574,7 @@ func cmdApply() *cobra.Command {
_ = cl.Status().Update(ctx, hr)
}

if err := upgradeRelease(cfg, hr, chartDir, vals); err != nil {
if err := upgradeRelease(cfg, hr, chartDir, vals, takeOwnership); err != nil {
markFailure(ctx, cl, nil, hr, err)
return err
}
Expand All @@ -592,6 +595,7 @@ func cmdApply() *cobra.Command {
cmd.Flags().BoolVar(&plain, "plain", false, "Install chart without querying values from the HelmRelease")
cmd.Flags().BoolVar(&autoResume, "resume", false, "Automatically clear spec.suspend after successful apply")
cmd.Flags().StringSliceVarP(&extraVals, "values", "f", nil, "Additional values files (may be repeated)")
cmd.Flags().BoolVar(&takeOwnership, "take-ownership", false, "Take ownership of existing resources")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The help text for --take-ownership is a bit generic. To avoid potential misuse by users who might not be deeply familiar with Helm's behavior, it would be beneficial to make it more specific. A more descriptive help text can clarify that this option applies to existing resources that match the release's manifests but are not currently under its management, which aligns better with Helm's own documentation.

Suggested change
cmd.Flags().BoolVar(&takeOwnership, "take-ownership", false, "Take ownership of existing resources")
cmd.Flags().BoolVar(&takeOwnership, "take-ownership", false, "Take ownership of existing resources that match the release but are not managed by it")

return cmd
}

Expand Down
Loading