-
Notifications
You must be signed in to change notification settings - Fork 18
Apply go 1.18 generics across reconciler-runtime #349
Conversation
This is a major breaking change that will affect all users of reconciler-runtime. There does not appear to be a way to transparently apply generics to an existing API that allows users to opt-in over time. User defined functions are now compile-time type checked, and IDEs will be able to offer completion for method signatures. At runtime these functions are directly invoked and are no longer called by reflection. Runtime type checking has been removed. Changes: - All existing deprecations are removed - All Reconcilers and SubReconcilers now operate on generic types of client.Object. - All reconciler Type/ChildType/ChildListType fields are now optional. They are only required if the generic type is an interface, or to define the apiVersion/kind for an Unstructured type. - SyncReconciler#Sync and #Finalize methods are split into two fields, one that is _WithResult and the default method which only returns an error. Signed-off-by: Scott Andrews <andrewssc@vmware.com>
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #349 +/- ##
==========================================
- Coverage 60.36% 58.08% -2.28%
==========================================
Files 17 14 -3
Lines 2210 1954 -256
==========================================
- Hits 1334 1135 -199
+ Misses 798 741 -57
Partials 78 78
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
Updated the service binding runtime to use this branch scothis/servicebinding-runtime#113 |
The Type field for CastResource is completely redundant with the generic types. We can also go a step further and avoid converting the resource when the CastType is an interface, because we know all concrete types are already compatible and only need to be cast, saving a lot of overhead. Signed-off-by: Scott Andrews <andrewssc@vmware.com>
Signed-off-by: Scott Andrews <andrewssc@vmware.com>
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.
lgtm
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.
After test-driving this branch with our kit, I approve 👍🏻
Great work, @scothis
This means that the value of Resource and ExpectedResource must be the same type as the reconciler handles. No longer can a die be passed directly and unwrapped inside the test. While this behavior was extremely convenient, it created expectations that may not be true in other cases and depends on DeepCopyObject on the die returning a different type than the method was called on. Signed-off-by: Scott Andrews <andrewssc@vmware.com>
This is a major breaking change that will affect all users of reconciler-runtime. There does not appear to be a way to transparently apply generics to an existing API that allows users to opt-in over time.
User defined functions are now compile-time type checked, and IDEs will be able to offer completion for method signatures. At runtime these functions are directly invoked and are no longer called by reflection. Runtime type checking has been removed.
Changes:
Resolves #163