Skip to content

Conversation

@kvaps
Copy link
Member

@kvaps kvaps commented Nov 18, 2025

Signed-off-by: Andrei Kvapil [email protected]

Summary by CodeRabbit

Release Notes

  • New Features
    • Added a new take-ownership flag in the apply command that enables users to control resource ownership behavior when creating new releases or upgrading existing ones.

@gemini-code-assist
Copy link

Summary of Changes

Hello @kvaps, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the apply command by introducing a --take-ownership flag. This new option allows the underlying Helm operations to assume ownership of existing Kubernetes resources, providing greater flexibility and preventing conflicts when deploying applications where resources might already be present or managed externally. The change propagates this ownership setting through the upgradeRelease function to the Helm install and upgrade actions.

Highlights

  • New Command-Line Option: Introduced a new --take-ownership flag for the apply command, allowing users to specify whether Helm operations should take ownership of existing resources.
  • Function Signature Update: The upgradeRelease function now accepts a takeOwnership boolean parameter to control resource ownership behavior during Helm installs and upgrades.
  • Helm Action Configuration: The helmaction.Install and helmaction.Upgrade objects are now configured with the TakeOwnership flag based on the value provided by the new command-line option.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a --take-ownership option to the apply command, which is then passed to the underlying Helm install and upgrade actions. This allows Helm to adopt existing Kubernetes resources that are not currently managed by the release. The implementation is correct and straightforward. I have one suggestion to improve the clarity of the help text for the new flag to prevent potential misuse.

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")

@coderabbitai
Copy link

coderabbitai bot commented Nov 18, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

A new takeOwnership flag was added to the apply command and threaded through the upgradeRelease function to control Helm resource ownership behavior during release installation and upgrade operations.

Changes

Cohort / File(s) Summary
Helm ownership flag implementation
main.go
Added takeOwnership boolean parameter to upgradeRelease function signature; introduced new take-ownership flag in apply command to expose ownership control to users; updated apply flow to propagate flag value to upgradeRelease and set TakeOwnership on Helm install and upgrade actions.

Sequence Diagram

sequenceDiagram
    participant User
    participant ApplyCmd as Apply Command
    participant UpgradeRelease
    participant HelmAction as Helm Action (Install/Upgrade)

    User->>ApplyCmd: Execute with --take-ownership flag
    ApplyCmd->>ApplyCmd: Parse takeOwnership flag
    ApplyCmd->>UpgradeRelease: Call upgradeRelease(..., takeOwnership)
    UpgradeRelease->>HelmAction: Create Install/Upgrade action
    UpgradeRelease->>HelmAction: Set TakeOwnership = takeOwnership
    HelmAction->>HelmAction: Apply Helm release with ownership setting
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify the takeOwnership parameter is correctly passed through all execution paths (both install and upgrade scenarios)
  • Confirm the flag definition in the apply command matches expected naming and default behavior
  • Check that TakeOwnership is set on both Helm action types (Install and Upgrade)

Poem

🐰 With ownership flags now held tight,
Our Helm releases take flight,
No more resource disputes in sight—
The apply command sets things right!
hop

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and concisely describes the main change: introducing a new --take-ownership option, which aligns with the additions of the takeOwnership parameter and flag throughout the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch take-ownership

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f28689 and 3f90d60.

📒 Files selected for processing (1)
  • main.go (6 hunks)
🔇 Additional comments (6)
main.go (6)

299-299: LGTM: Function signature updated correctly.

The addition of the takeOwnership parameter is clean and follows Go conventions by appending it to the end of the parameter list.


314-324: LGTM: Install path correctly configured.

The TakeOwnership field is properly set on the Install action, enabling resource adoption during initial installation.


326-336: LGTM: Upgrade path correctly configured.

The TakeOwnership field is properly set on the Upgrade action, ensuring consistent behavior whether the release is being installed or upgraded.


527-527: LGTM: Variable declaration follows existing patterns.

The takeOwnership variable is appropriately scoped to the apply command, consistent with other command-specific flags like autoResume.


577-577: LGTM: Flag value correctly propagated.

The takeOwnership flag is properly passed through to upgradeRelease, completing the data flow from CLI to Helm actions.


318-318: No changes required — TakeOwnership field is supported in Helm v3.18.2.

Helm 3.18.2 includes support for the "take ownership" option with both a client field and CLI flag (--take-ownership on upgrade/install). The code correctly uses this field for the supported Helm version.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kvaps kvaps merged commit b5284eb into main Nov 19, 2025
2 of 3 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants