Open
Description
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.