feat: Add --replace flag to crossplane xrd generate - #243
Conversation
Signed-off-by: Cyrill Näf <cyrill.naef@gmail.com>
📝 WalkthroughWalkthroughThe XRD generate command adds an optional ChangesXRD generation replacement
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
cmd/crossplane/xrd/generate.go (1)
131-132: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExpose a stable existing-file error cause. The formatted-only error at
cmd/crossplane/xrd/generate.golines 131-132 forces text-based assertions incmd/crossplane/xrd/generate_test.go.
cmd/crossplane/xrd/generate.go#L131-L132: return or wrap a stable sentinel or typed existing-file error while preserving the actionable path and--replacecontext.cmd/crossplane/xrd/generate_test.go#L773-L827: addwant.errandreason, then compare the stable error withcmp.Diffandcmpopts.EquateErrors().🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cmd/crossplane/xrd/generate.go` around lines 131 - 132, Expose a stable sentinel or typed existing-file error from the Replace check in cmd/crossplane/xrd/generate.go lines 131-132, wrapping it while retaining the file path and --replace guidance; update cmd/crossplane/xrd/generate_test.go lines 773-827 to add want.err and reason fields and compare errors with cmp.Diff and cmpopts.EquateErrors().Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/crossplane/xrd/generate_test.go`:
- Around line 800-810: Extend the tests around generateCmd.Run to invoke the
command through Kong parsing with the --replace flag instead of assigning
Replace directly, then assert the parsed command has replacement enabled and
preserves the existing replacement behavior. Use the generate command’s Kong
struct definition and normal xrd generate argument path so the test detects
broken flag names or bindings.
---
Nitpick comments:
In `@cmd/crossplane/xrd/generate.go`:
- Around line 131-132: Expose a stable sentinel or typed existing-file error
from the Replace check in cmd/crossplane/xrd/generate.go lines 131-132, wrapping
it while retaining the file path and --replace guidance; update
cmd/crossplane/xrd/generate_test.go lines 773-827 to add want.err and reason
fields and compare errors with cmp.Diff and cmpopts.EquateErrors().
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 5c0300a5-cc9e-438a-bc2c-790218b0544b
📒 Files selected for processing (2)
cmd/crossplane/xrd/generate.gocmd/crossplane/xrd/generate_test.go
Description of your changes
Adding a
--replaceflag tocrossplane xrd generatecommand instructing it to create or if exists replace thedefinition.yamlfile.Fixes #216
I have:
./nix.sh flake checkto ensure this PR is ready for review.backport release-x.ylabels to auto-backport this PR.Need help with this checklist? See the cheat sheet.