Skip to content

Defer CLI receiver methods refactor to v5 #4762

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

Open
camilamacedo86 opened this issue Apr 5, 2025 · 0 comments
Open

Defer CLI receiver methods refactor to v5 #4762

camilamacedo86 opened this issue Apr 5, 2025 · 0 comments
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. triage/blocked

Comments

@camilamacedo86
Copy link
Member

camilamacedo86 commented Apr 5, 2025

This issue tracks PR #4675, which proposes changing CLI method receivers from values to pointers.

Why defer?
This change introduces a breaking change to the public CLI API, affecting consumers like Operator SDK and others that embed or extend Kubebuilder’s CLI logic.

While a workaround was suggested in the PR (retaining the old method for compatibility and adding a new one with a pointer receiver):

// Deprecated: Use (c *CLI).CommandPtr() instead.
func (c CLI) Command() *cobra.Command {
	return (&c).CommandPtr()
}

func (c *CLI) CommandPtr() *cobra.Command {
	return c.cmd
}

This approach avoids an immediate breakage, but comes with trade-offs:

  • It introduces an awkwardly named method (CommandPtr) that would have to be supported indefinitely.
  • It sets a precedent for duplicate APIs instead of clean versioning.
  • It doesn’t eliminate the risk of confusion or future maintenance issues for projects that consumes Kubebuilder as a lib.

Since this is a public API and widely used by consumers, we believe the cleanest and safest approach is to defer this change to Kubebuilder v5, where breaking changes are expected and better managed.

@camilamacedo86 camilamacedo86 added this to the kubebuilder 5x milestone Apr 5, 2025
@camilamacedo86 camilamacedo86 added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. triage/blocked labels Apr 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. triage/blocked
Projects
None yet
Development

No branches or pull requests

1 participant