Skip to content
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

Patch ordering #7

Merged
merged 13 commits into from
Nov 30, 2023
Merged

Patch ordering #7

merged 13 commits into from
Nov 30, 2023

Conversation

stevendborrelli
Copy link
Owner

This PR pulls in the changes from upstream function-patch-and-transform PR crossplane-contrib#55.

The below text was copied from the upstream PR:

Fixes crossplane-contrib#54
Fixes crossplane-contrib#48

Fixes

Execute resources[*].patches in order (crossplane-contrib#54)

Before this change, patches at resources[*].patches were executed as follows:

  • RenderToCompositePatches: all *ToComposite* patches from the observed composed resource to the desired XR (ocd => dxr)
  • RenderToEnvironmentPatches: all *ToEnvironment* patches from the observed composed resource to the environment (ocd => env)
  • RenderFromCompositePatches: all *FromComposite* patches from the environment to the desired composed resourceoxr => dcd
  • RenderFromEnvironmentPatches: all *FromEnvironment* patches from the environment to the desired composed resource (env => dcd)

With this change, patches at resources[*].patches will be executed in order as in Crossplane (<=v1.13, >1.14.2), properly selecting the right source and destination between the desired and observed XR or composed resource.

This allows the example at crossplane-contrib#54 to work properly.

CRD properly generated (crossplane-contrib#48)

Before this change, we had a single type of patch for all occurrences, resources[*].patches, environment.patches, patchSets[*].patches, this meant that the generated CRD had, depending on the cases, the wrong enum options for the patch type, allowed defining and documented wrong types.

With this change, the CRD is generated correctly.

Refactoring

For the sake of consistency with what we did for the fix above, we decided to refactor the code to also execute in order environment patches, although afaict the previous implementation was already behaving correctly.

Before this change, patches at environment.patches[*] were run as follows:

  • RenderToEnvironmentPatches: all *ToEnvironment* patches from the observed XR to the environment (oxd => env)
  • RenderFromEnvironmentPatches: all *FromEnvironment* patches from the desired XR to the environment (env => dxd)

With this change, patches at environment.patches[*] will be executed in order as in Crossplane (<=v1.14), properly selecting the right source and destination between the desired and observed composite.

@stevendborrelli stevendborrelli merged commit 436ba40 into main Nov 30, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants