Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Execute
resources[*].patches
in order (crossplane-contrib#54)Before this change, patches at
resources[*].patches
were executed as follows:*ToComposite*
patches from the observed composed resource to the desired XR (ocd => dxr)*ToEnvironment*
patches from the observed composed resource to the environment (ocd => env)*FromComposite*
patches from the environment to the desired composed resourceoxr => dcd*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:*ToEnvironment*
patches from the observed XR to the environment (oxd => env)*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.