-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
✨ Add reconcile.ObjectReconciler #2592
✨ Add reconcile.ObjectReconciler #2592
Conversation
Welcome @JamesOwenHall! |
Hi @JamesOwenHall. 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 Once the patch is verified, the new status will be reflected by the 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/test-infra repository. |
} | ||
|
||
// AsReconciler creates a Reconciler based on the given ObjectReconciler. | ||
func AsReconciler[T client.Object](client client.Client, rec ObjectReconciler[T]) Reconciler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #2582 (comment), @alvaroaleman proposed adding a new method to builder.Builder
so that an adapter function like AsReconciler
here wouldn't be necessary. However, Go does not allow a method to add new type parameters, only a method receiver can define type parameters. Therefore, I believe that adding a Builder.CompleteObjectReconciler
method would only be possible if Builder
defined a type parameter, i.e. Builder[T client.Object]
. I don't think this type parameter makes much sense for instances of reconcile.Reconciler
so I opted to use an adapter function instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually realized the same thing later on while being on a walk, so agree 👍
/ok-to-test |
I'm not sure what else this needs but after reviewing it, it looks good to me. /lgtm |
So @vincepri @sbueringer and myself had a bit of discussion around this and weren't really sure if this is what we want. Given that this is a rather trivial change that can easily be managed downstream, we'd like to defer merging this for now. We can probably use one of the issues to discuss this and see if we can up with something everyone is comfortable with. |
/hold |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JamesOwenHall, vincepri The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold cancel |
Part of #2582.
Fixes #2221.
This PR adds a new
reconcile.ObjectReconciler
interface to eliminate the following common boilerplate.ObjectReconciler
leverages generics to write reconcilers in terms of deserialized instances ofclient.Object
. It does not replace the existingreconcile.Reconciler
interface.Developers can create a controller with an
ObjectReconciler
by calling theAsReconciler
function.