-
Notifications
You must be signed in to change notification settings - Fork 594
feat(snapshots): Add JSON output flag for snapshot verify #4644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* Add JSON output flag for snapshot verify
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4644 +/- ##
==========================================
+ Coverage 75.86% 76.43% +0.57%
==========================================
Files 470 529 +59
Lines 37301 40201 +2900
==========================================
+ Hits 28299 30729 +2430
- Misses 7071 7456 +385
- Partials 1931 2016 +85 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds JSON output support for the snapshot verify command by returning a structured VerifierResult from the verifier, exposing tree-walker errors via a new GetErrors method, and wiring a --json flag into the CLI.
- Introduce
VerifierResultand updateInParallelto return it with JSON tags. - Add
GetErrorsonTreeWalkerto expose accumulated errors. - Extend CLI to handle
--json, suppress default stats, and print JSON; update tests accordingly.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| snapshot/snapshotfs/snapshot_verifier_test.go | Updated tests to use new VerifierResult return and check counts and error slices. |
| snapshot/snapshotfs/snapshot_verifier.go | Added VerifierResult type and modified InParallel to build and return it. |
| snapshot/snapshotfs/snapshot_tree_walker.go | Added GetErrors to retrieve a thread-safe copy of errors and count. |
| cli/command_snapshot_verify.go | Added JSON flag handling, suppressed default stats, and printed JSON output. |
| cli/command_snapshot_verify_test.go | Added tests for the --json flag and validation of JSON-formatted results. |
Comments suppressed due to low confidence (2)
snapshot/snapshotfs/snapshot_verifier_test.go:70
- [nitpick] Consider adding an assertion on
result.ErrorStrings[0]to verify that the JSON-serializable string matches the expected error message.
require.ErrorIs(t, result.Errors[0], someErr)
snapshot/snapshotfs/snapshot_verifier_test.go:152
- The variable
erris not declared in this scope before use inresult, err = v.InParallel(...), causing a compile error. Declarevar err erroror use:=to defineerralongsideresult.
var result *snapshotfs.VerifierResult
| c.out.printStdout("%s\n", c.jo.jsonIndentedBytes(result, " ")) | ||
| } | ||
|
|
||
| //nolint:wrapcheck |
Copilot
AI
Jun 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The //nolint:wrapcheck directive is now obsolete since the wrapped call was removed; consider removing this nolint comment.
| //nolint:wrapcheck |
Add JSON output flag for snapshot verify. Return and output a JSON-formatted result including stats and error strings.