Skip to content

🌱 (chore): convert plugin.Version receiver methods to use pointer receiver #4733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

kersten
Copy link
Contributor

@kersten kersten commented Apr 1, 2025

This PR updates all implementations of the plugin.Plugin interface to return *plugin.Version instead of plugin.Version by value.

Motivation

  • Prevents unnecessary copies of the version struct
  • Makes pointer semantics explicit and consistent across plugins and mocks

Changes

  • Updated all .Version() implementations to return a pointer
  • Updated plugin.Version method receivers (e.g., Validate, Compare, String) to pointer receivers
  • Adjusted affected test mocks and helpers

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 1, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: kersten
Once this PR has been reviewed and has the lgtm label, please assign kavinjsir for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

Hi @kersten. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 1, 2025
…eiver

This change updates methods on the `plugin.Version` type to use pointer receivers instead of value receivers.
@kersten kersten force-pushed the chore/plugin-version-pointer-methods branch from 490103b to 90c0d3d Compare April 2, 2025 14:22
@camilamacedo86
Copy link
Member

The issue with this one is that it would break the API.

Also, deprecating it isn't ideal either, because we'd end up with a strange name that we’d have to support indefinitely.

So I’ll need some time to properly review and evaluate this case before moving forward.

@camilamacedo86
Copy link
Member

Hi @kersten

Thank you for this contribution! 🎉

After analyse this one. Unfortunately, we cannot proceed with this change at the moment. It introduces a breaking change to a public API (plugin.Version) that is widely used in projects like Operator SDK as others which might consume Kubebuidler as a lib. Example: https://github.com/search?q=repo%3Aoperator-framework%2Foperator-sdk%20plugin.Version&type=code

While switching to pointer receivers may have internal benefits, the impact on existing consumers outweighs the value this change currently brings. Accepting it now would break compatibility for many users relying on value-based usage.

The best path forward would be to open an issue to track this enhancement. We can link this PR there and plan to revisit and include it as part of the work for a future major release — likely kubebuilder v5.x, where breaking changes are expected and manageable. I did this one: #4761 so I hope that you do not mind but I am closing this one as deferred.

Thanks again for the effort and your understanding!

Best regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants