vmware-labs / reconciler-runtime

⚠️ Maintenance suspended. Please, migrate to the active fork reconciler.io/runtime. See https://github.com/reconcilerio/runtime/releases/tag/v0.20.0 for instructions. This repository will be archived eventually.
Other
81 stars 18 forks source link

Duck type clients and reconcilers #402

Closed scothis closed 11 months ago

scothis commented 11 months ago

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:

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.

Resolves #53

codecov[bot] commented 11 months ago

Codecov Report

Patch coverage: 39.24% and project coverage change: -0.74% :warning:

Comparison is base (4dff503) 61.36% compared to head (d3cd0cc) 60.62%.

:exclamation: Current head d3cd0cc differs from pull request most recent head 7256938. Consider uploading reports for the commit 7256938 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #402 +/- ## ========================================== - Coverage 61.36% 60.62% -0.74% ========================================== Files 24 24 Lines 2275 2334 +59 ========================================== + Hits 1396 1415 +19 - Misses 796 835 +39 - Partials 83 84 +1 ``` | [Files Changed](https://app.codecov.io/gh/vmware-labs/reconciler-runtime/pull/402?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vmware-labs) | Coverage Δ | | |---|---|---| | [apis/conditionset.go](https://app.codecov.io/gh/vmware-labs/reconciler-runtime/pull/402?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vmware-labs#diff-YXBpcy9jb25kaXRpb25zZXQuZ28=) | `3.72% <0.00%> (-0.17%)` | :arrow_down: | | [reconcilers/childset.go](https://app.codecov.io/gh/vmware-labs/reconciler-runtime/pull/402?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vmware-labs#diff-cmVjb25jaWxlcnMvY2hpbGRzZXQuZ28=) | `87.87% <ø> (ø)` | | | [reconcilers/config.go](https://app.codecov.io/gh/vmware-labs/reconciler-runtime/pull/402?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vmware-labs#diff-cmVjb25jaWxlcnMvY29uZmlnLmdv) | `60.86% <0.00%> (ø)` | | | [testing/reconciler.go](https://app.codecov.io/gh/vmware-labs/reconciler-runtime/pull/402?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vmware-labs#diff-dGVzdGluZy9yZWNvbmNpbGVyLmdv) | `0.00% <0.00%> (ø)` | | | [testing/subreconciler.go](https://app.codecov.io/gh/vmware-labs/reconciler-runtime/pull/402?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vmware-labs#diff-dGVzdGluZy9zdWJyZWNvbmNpbGVyLmdv) | `0.00% <0.00%> (ø)` | | | [testing/webhook.go](https://app.codecov.io/gh/vmware-labs/reconciler-runtime/pull/402?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vmware-labs#diff-dGVzdGluZy93ZWJob29rLmdv) | `0.00% <0.00%> (ø)` | | | [reconcilers/aggregate.go](https://app.codecov.io/gh/vmware-labs/reconciler-runtime/pull/402?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vmware-labs#diff-cmVjb25jaWxlcnMvYWdncmVnYXRlLmdv) | `60.83% <7.69%> (-5.84%)` | :arrow_down: | | [reconcilers/resource.go](https://app.codecov.io/gh/vmware-labs/reconciler-runtime/pull/402?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vmware-labs#diff-cmVjb25jaWxlcnMvcmVzb3VyY2UuZ28=) | `74.09% <62.22%> (-4.44%)` | :arrow_down: | | [reconcilers/webhook.go](https://app.codecov.io/gh/vmware-labs/reconciler-runtime/pull/402?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vmware-labs#diff-cmVjb25jaWxlcnMvd2ViaG9vay5nbw==) | `90.38% <100.00%> (+0.09%)` | :arrow_up: | | [testing/config.go](https://app.codecov.io/gh/vmware-labs/reconciler-runtime/pull/402?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vmware-labs#diff-dGVzdGluZy9jb25maWcuZ28=) | `87.55% <100.00%> (ø)` | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/vmware-labs/reconciler-runtime/pull/402/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vmware-labs)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.