feat: support composition revisions #80
Merged
+3,226
−205
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.
Description of your changes
This PR adds support for Crossplane's composition revision system and automatic/manual update policies in
crossplane-diff
, ensuring diffs accurately reflect how Crossplane will render XRs based on their configuredupdate strategy.
Composition Revision Resolution
When diffing XRs,
crossplane-diff
now intelligently resolves which composition version to use based on theXR's
compositionUpdatePolicy
andcompositionRevisionRef
fields:Automatic Update Policy: XRs with
compositionUpdatePolicy: Automatic
(the default) always use the latestCompositionRevision
for their composition. This mirrors Crossplane's behavior where automatic XRs arecontinuously upgraded to the newest composition version.
Manual Update Policy: XRs with
compositionUpdatePolicy: Manual
use the specificCompositionRevision
referenced in their
spec.crossplane.compositionRevisionRef
field. This allows users to see diffs for XRs thatare pinned to a specific composition version.
Fallback Behavior: If composition revisions cannot be found (e.g., for newly created compositions),
crossplane-diff
falls back to using theComposition
resource directly.New CLI Flag:
--include-manual
The
comp
command now includes an--include-manual
flag that controls which XRs are included in the diffoutput:
Default behavior (
--include-manual=false
): Only shows diffs for XRs withAutomatic
update policy,since these are the XRs that will actually be affected by composition changes.
With
--include-manual
: Includes XRs withManual
update policy in the diff output, allowing users tosee the potential impact if they were to upgrade these manually-pinned XRs.
This filtering ensures users see relevant results by default, while still allowing inspection of
manually-managed XRs when needed.
Implementation Details
CompositionRevisionClient
to handle fetching and resolvingCompositionRevision
resourcesCompositionClient.FindMatchingComposition()
to use revision-based resolution viaresolveCompositionFromRevisions()
CompDiffProcessor.filterXRsByUpdatePolicy()
compositionRevisionRef
field before validation, as it's set byCrossplane controllers and may not be present in all XRD schemas
Fixes #71.
I have:
earthly +reviewable
to ensure this PR is ready for review.- [ ] Linked a PR or a docs tracking issue to document this change.- [ ] Followed the API promotion workflow if this PR introduces, removes, or promotes an API.Need help with this checklist? See the cheat sheet.