Skip to content

🌱 add structured output from validation with 'output' option#1971

Merged
openshift-merge-bot[bot] merged 2 commits intooperator-framework:masterfrom
grokspawn:validation-structured-output
May 1, 2026
Merged

🌱 add structured output from validation with 'output' option#1971
openshift-merge-bot[bot] merged 2 commits intooperator-framework:masterfrom
grokspawn:validation-structured-output

Conversation

@grokspawn
Copy link
Copy Markdown
Contributor

@grokspawn grokspawn commented May 1, 2026

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

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Docs updated or added to /docs
  • Commit messages sensible and descriptive

Copilot AI review requested due to automatic review settings May 1, 2026 15:04
@openshift-ci openshift-ci Bot requested review from oceanc80 and perdasilva May 1, 2026 15:04
@grokspawn grokspawn changed the title add structured output from validation with 'output' option 🌱 add structured output from validation with 'output' option May 1, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 / ValidationError types for structured validation output.
  • Adds --output (json|yaml) flag to opm 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.

Comment thread cmd/opm/validate/validate.go Outdated
Comment thread cmd/opm/validate/validate.go Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.70%. Comparing base (bd6255d) to head (5e8280f).
⚠️ Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

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

Signed-off-by: grokspawn <jordan@nimblewidget.com>
@grokspawn grokspawn force-pushed the validation-structured-output branch from e366073 to a1bdb0a Compare May 1, 2026 15:11
@tmshort
Copy link
Copy Markdown
Contributor

tmshort commented May 1, 2026

/approve

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 1, 2026
grokspawn added a commit to grokspawn/operator-registry that referenced this pull request May 1, 2026
- 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
Copilot AI review requested due to automatic review settings May 1, 2026 15:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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) for opm validate and emits a structured {passed, error} payload to stdout.
  • Returns the validation error (when --output is 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.

Comment thread cmd/opm/validate/validate.go Outdated
Comment thread cmd/opm/validate/validate.go
Comment thread cmd/opm/validate/validate.go Outdated
- 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
@grokspawn grokspawn force-pushed the validation-structured-output branch from d0b69de to 5e8280f Compare May 1, 2026 17:44
Copy link
Copy Markdown
Member

@rashmigottipati rashmigottipati left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label May 1, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 1, 2026

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot Bot merged commit f40a355 into operator-framework:master May 1, 2026
13 checks passed
@grokspawn grokspawn deleted the validation-structured-output branch May 1, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants