🌱 add structured output from validation with 'output' option#1971
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an --output/-o option to opm validate to emit machine-readable validation results (JSON/YAML) instead of relying solely on exit status and log output.
Changes:
- Introduces
ValidationResult/ValidationErrortypes for structured validation output. - Adds
--output (json|yaml)flag toopm validate. - Implements marshaling/printing of structured results and adjusts exit behavior in output mode.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1971 +/- ##
=======================================
Coverage 57.70% 57.70%
=======================================
Files 139 139
Lines 13360 13360
=======================================
Hits 7709 7709
Misses 4466 4466
Partials 1185 1185 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: grokspawn <jordan@nimblewidget.com>
e366073 to
a1bdb0a
Compare
|
/approve |
- Remove unused Errors field from ValidationError struct The field was never populated, making the structure misleading. Simplified to match actual implementation (single message). - Replace os.Exit with cobra error handling Use SilenceErrors/SilenceUsage instead of os.Exit to: - Allow deferred cleanup and hooks to run - Make command unit-testable and composable - Follow cobra best practices Exit code behavior verified unchanged (0=success, 1=failure) Addresses feedback from Copilot and tmshort on PR operator-framework#1971
There was a problem hiding this comment.
Pull request overview
Adds an --output/-o option to opm validate so callers can receive structured JSON/YAML output (instead of relying solely on exit status / log output), while preserving the existing default behavior when --output is not provided.
Changes:
- Introduces
--output/-o (json|yaml)foropm validateand emits a structured{passed, error}payload to stdout. - Returns the validation error (when
--outputis set) to preserve non-zero exit codes while suppressing cobra usage/error text to avoid contaminating structured output. - Adds lightweight structs/helpers for representing validation results in JSON/YAML.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove unused Errors field from ValidationError struct The field was never populated, making the structure misleading. Simplified to match actual implementation (single message). - Replace os.Exit with cobra error handling Use SilenceErrors/SilenceUsage instead of os.Exit to: - Allow deferred cleanup and hooks to run - Make command unit-testable and composable - Follow cobra best practices Exit code behavior verified unchanged (0=success, 1=failure) Addresses feedback from Copilot and tmshort on PR operator-framework#1971
d0b69de to
5e8280f
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rashmigottipati, tmshort The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
f40a355
into
operator-framework:master
Description of the change:
Provides JSON/YAML structured output option from
opm validate, in case callers need more info than an exit status. Documentation for this fucntionality is in this PR.Motivation for the change:
Reviewer Checklist
/docs