Skip to content

fix(xr): set generateName on the XR generated from a Claim - #617

Open
tampakrap wants to merge 2 commits into
crossplane:mainfrom
tampakrap:theo/fix_xr_generate_generatename
Open

tampakrap wants to merge 2 commits into
crossplane:mainfrom
tampakrap:theo/fix_xr_generate_generatename

Conversation

@tampakrap

Copy link
Copy Markdown
Collaborator

Description of your changes

Crossplane creates the XR of a claim with metadata.generateName set to the Claim's name and a hyphen, and the API server appends the random suffix to make the name.

Set generateName on the generated XR as well, so that it matches the XR Crossplane creates. A direct XR is unchanged.

Related:

I have:

  • Read and followed Crossplane's contribution process.
  • Read and followed Crossplane's AI policy and confirmed a human stands behind this PR.
  • Run ./nix.sh flake check to ensure this PR is ready for review.
  • Added or updated unit tests.
  • Linked a PR or a docs tracking issue to document this change.
  • Added backport release-x.y labels to auto-backport this PR.

Need help with this checklist? See the cheat sheet.

Crossplane creates the XR of a claim with `metadata.generateName` set to
the Claim's name and a hyphen, and the API server appends the random
suffix to make the name.

Set `generateName` on the generated XR as well, so that it matches the
XR Crossplane creates. A direct XR is unchanged.

Signed-off-by: Theo Chatzimichos <tampakrap@gmail.com>
@tampakrap
tampakrap requested review from a team and jcogilvie as code owners November 26, 2026 13:24
@tampakrap
tampakrap requested review from phisco and a balanced review from Copilot and removed request for a team November 26, 2026 13:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The shared test expectation builder omits metadata.generateName, causing the missing-backing-XR, new-claim, and unbound-claim tests to fail their full-object comparisons.

1 open issue
What changed in this PR

Aligns claim-derived composite resources (XRs) generated by the CLI with Crossplane’s metadata, supporting rendering and composition-testing workflows.

Changes:

  • Sets metadata.generateName to <claim-name>- for claim-derived XRs, including those with an explicit name.
  • Updates converter test expectations while leaving direct-XR behavior unchanged.
File Description
pkg/​xr/​claim.go Adds claim-derived generateName in non-direct mode.
pkg/​xr/​claim_test.go Updates expected metadata for claim-derived XRs.

Review effort: Balanced

Comment thread pkg/xr/claim.go Resolved
@tampakrap
tampakrap marked this pull request as draft November 26, 2026 13:56
`ConvertClaimToXR` now sets `metadata.generateName` on the XR it
generates from a Claim, as Crossplane does for the XR of a Claim.

The composite resolver calls it (not direct, with an explicit name) to
synthesize the backing XR of a Claim that has none in the cluster, so
that XR carries `metadata.generateName` as well.

Add it to the expectation of the synthesized XR in the composite
resolver tests. Only the expectation changes: the resolver is not
touched, and the integration suites that exercise it (xr and composition
composition simulate) pass unchanged.

Signed-off-by: Theo Chatzimichos <tampakrap@gmail.com>
@codecov

codecov Bot commented Nov 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 72.43%. Comparing base (14a9f58) to head (928638f).

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tampakrap
tampakrap marked this pull request as ready for review November 26, 2026 14:32
Copilot AI balanced review requested due to automatic review settings November 26, 2026 14:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the claim-derived XR naming update.

1 open issue

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants