This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Duck type clients and reconcilers (#402)
The clients used by reconciler runtime are now able to interact with duck typed resources, with some limitations. The support extends to working inside reconcilers, including with the ResourceReconciler. Duck typed resources are structured types that implement the client.Object interface but are not registered in the scheme for a GVK. The APIVersion and Kind fields must be set on the object. Using ResourceReconciler with a duck type is similar to using an unstructured type and then casting to the duck type, however, starting with a duck type will allow the resource to participate in common structured operations like setting the status observed generation, initializing conditions, and coalescing condition timestamps when the condition did not otherwise change. Known limitations include: - Create client methods are not supported. Resources always need to be created with a concrete type. - Update client methods are not supported. Use Patch methods instead. - ResourceReconciler will patch status if a mutation is detected instead of update. The bytes of the patch must be defined on the ReconcilerTestCase for tests that result in a patch request. Ephemeral values, like LastTransitionTime timestamps, need to be pinned to known values. Use ReconcilerTestCase#Now for timestamp values. To help solve the ephemeral nature of time, this change also introduces a mechanism to retrieve the current time off the context via rtime.RetrieveNow. Each root reconciler stashes the current time. Additionally, each test case can define the Now field with a custom timestamp that is stashed as the current time. The condition manager Manage method is deprecated in favor of ManageWithContext, which will use the stashed time when constructing conditions. The status InitializeConditions method should be updated to accept a context when it is defined, the no arg variant is deprecated. When using either deprecated method without a context, time.Now is used instead of the stashed time. Signed-off-by: Scott Andrews <[email protected]>
- Loading branch information
Showing
23 changed files
with
1,606 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.