feat: optionally hide composition changes in comp subcommand#375
feat: optionally hide composition changes in comp subcommand#375fernandezcuesta wants to merge 2 commits into
Conversation
Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds an opt-in --hide-composition flag to the crossplane-diff comp subcommand so users can focus on affected XRs and their downstream diffs without always printing the composition diff section (addressing #371).
Changes:
- Introduces
HideCompositionplumbing from CLI (compsubcommand) → processor config → renderer options. - Updates human and structured (JSON/YAML) composition diff renderers to omit the composition diff when requested.
- Adds unit test coverage and updates README usage/docs.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the new --hide-composition flag and example usage. |
| cmd/diff/renderer/diff_formatter.go | Adds HideComposition to shared DiffOptions. |
| cmd/diff/renderer/comp_diff_renderer.go | Implements hiding composition diffs in human + structured renderers. |
| cmd/diff/renderer/comp_diff_renderer_test.go | Adds tests validating hidden composition output behavior. |
| cmd/diff/diffprocessor/processor_config.go | Plumbs HideComposition through processor config/options into renderer options. |
| cmd/diff/comp.go | Adds the --hide-composition CLI flag and wires it into processor options. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Render composition changes section. When --hide-composition is set we still | ||
| // surface processing errors (so failures aren't silently swallowed) but omit the | ||
| // composition diff itself. | ||
| if !r.opts.HideComposition || comp.Error != nil { | ||
| if err := r.renderCompositionChanges(&comp); err != nil { | ||
| return err | ||
| } | ||
| } |
Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>
| // Render composition changes section. When --hide-composition is set we still | ||
| // surface processing errors (so failures aren't silently swallowed) but omit the | ||
| // composition diff itself, including the section header. | ||
| if r.opts.HideComposition && comp.Error != nil { | ||
| if _, err := fmt.Fprintf(stdout, "Error processing composition %s: %s\n\n", comp.Name, comp.Error.Error()); err != nil { | ||
| return errors.Wrap(err, "cannot write composition error") | ||
| } | ||
| } else if !r.opts.HideComposition { | ||
| if err := r.renderCompositionChanges(&comp); err != nil { | ||
| return err | ||
| } | ||
| } |
| // Render composition changes section. When --hide-composition is set we still | ||
| // surface processing errors (so failures aren't silently swallowed) but omit the | ||
| // composition diff itself, including the section header. | ||
| if r.opts.HideComposition && comp.Error != nil { | ||
| if _, err := fmt.Fprintf(stdout, "Error processing composition %s: %s\n\n", comp.Name, comp.Error.Error()); err != nil { | ||
| return errors.Wrap(err, "cannot write composition error") | ||
| } |
|
(output from claude based on back and forth with me -- ideas are mine, i just had it do a summary writeup) PR #375 review — reframe
|
jcogilvie
left a comment
There was a problem hiding this comment.
see review feedback comment on the PR at large
Description of your changes
Fixes #371
I have:
earthly -P +reviewableto ensure this PR is ready for review.- [ ] Added or updated e2e tests.- [ ] Followed the API promotion workflow if this PR introduces, removes, or promotes an API.Need help with this checklist? See the cheat sheet.