Repository navigation
Description
What is the version of your ORAS CLI
v1.4.0 / main (oras-go v3.0.0)
What would you like to be added?
Part of #1791. Depends on #2359, and the output should also cover the results added in #2360. This makes oras check easier to use in pipelines and interactively.
Scope
Three independent parts, each a separate PR, in this order:
- Formatted output:
--format jsonand--format go-template. - Multiple tags:
oras check localhost:5000/hello:v1,v2,v3. - TTY progress: byte progress for each node, in the style of
oras cp.
Evaluation
Feasible after #2359. Effort is large as a whole: formatted output is small to medium, multiple tags and TTY progress are medium. Formatted output comes first because it fixes the result model that the other two use. Its schema should allow several artifacts from the start, so that multiple tags do not change it.
The parts are additive. The main risks are showing a failed or unfinished check as a success, and a schema that is hard to change later.
These behaviors were observed in scratch tests against oras-go v3.0.0 and the progress code on main:
| Scenario | Result | What oras check needs to do |
|---|---|---|
Intact layer shared by three tags, one VerifiedSet |
Fetched once, also when the tags ran in parallel | Share the set; run tags in sequence, as VerifyGraph is already concurrent |
| Corrupt layer shared by three tags | Fetched three times | Remember failures |
Same, remembering failures and returning SkipNode from PreVerify |
Fetched once, but report.OK() is true for the second and third tag |
Add the remembered failures to each tag's result; do not rely on OK() |
oras.FailedNode as JSON |
The error becomes {} |
Use a model of our own |
| Node cancelled during a read | PreVerify without PostVerify |
Do not rely on PostVerify to finish a tracker |
| Progress manager closed while a tracker is open | Close hangs |
Close every tracker first |
Tracker.Fail |
Shown with a red mark, also after the whole content was read, and after or before Done |
Use it; no new state is needed |
Repository wrapped in a struct to track Fetch |
No longer a registry.ReferrerLister |
Wrap only for the walk; list referrers on the original target |
| Empty index | Fetched twice in one walk | Keep one tracker per descriptor |
From reading the code: closing a tracker without calling Fail marks it as done, so a cancelled node would show a check mark. Render does not show the error text. The manager only draws the last rows that fit on the screen, so failures can scroll out of view.
Proposed implementation: formatted output
-
Add a check model in
metadata/model, with JSON, template and text handlers, andSetTypesas inpull. -
Suggested schema:
{ "ok": false, "complete": true, "artifacts": [ { "reference": "localhost:5000/hello@sha256:...", "tags": ["v1"], "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:...", "size": 1022, "ok": false, "verified": 3, "skipped": 0, "failures": [ { "class": "corrupt", "message": "mismatched digest", "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", "digest": "sha256:...", "size": 3638273 } ], "warnings": [] } ] }classis one of the four in Addoras checkto verify the integrity of an artifact #2359:missing,corrupt,invalid,unable-to-check. Findings for a whole layout in Support referrers and whole OCI layouts inoras check#2360 have no descriptor, and need a separate list with a path. -
Render the report before returning the failure, so that standard output has the report and standard error has the error.
pullonly renders on success, so it is not a model for this. -
On cancellation, render what was checked with
completeset to false.okmust be false whenevercompleteis false. -
Sort artifacts in the order requested and failures as in Add
oras checkto verify the integrity of an artifact #2359. Use empty lists instead ofnull.
Proposed implementation: multiple tags
- Split the reference on commas for a registry and for
--oci-layout. Do not split it for--oci-layout-path, where the reference name is stored as is. Reject a digest in a list. - Resolve every tag and record the ones that fail.
resolveTagsinbackup.gostops at the first error, andparseArtifactReferencesrejects digests and only handles registry references, so neither can be reused as is. - Group tags that resolve to the same digest and check it once.
- Share one
VerifiedSetfor one storage. Never share it between storages. - Remember missing, corrupt and invalid nodes by descriptor, and report them for every artifact that uses them. Do not remember nodes that could not be checked, because a later attempt may succeed.
Proposed implementation: TTY progress
- Add a tracked fetcher next to
status/track.Target, which only tracksPush. Keep the original target for resolving and listing referrers. - Start a tracker on the first fetch of a descriptor, and wrap the content with
progress.TrackReader. - Finish the tracker in
PostVerify:Doneif verification passed, otherwiseFail. A mismatch is only known after the whole content was read, so the reader cannot decide this. A node that fails before any content is read also needs a tracker. - When the walk ends, call
Failand thenCloseon every open tracker before closing the manager. - Print the summary with all failures after the progress display has stopped.
Design decisions to confirm
- JSON schema. Proposal: as above, marked experimental with the command.
- Repository without a tag. Proposal: keep it an error. Checking every tag, as
oras backupdoes, can be a very large download and should need an explicit flag. - Verified nodes in JSON. Proposal: only the counts, because a list can be very long.
- Progress wording. Improve progress output and add a summary for human readability #1784, Improve progress output of oras backup/restore for better human readability #1794 and Add status output to show the command execution result #1575 propose changes to progress and summary output in the same milestone as Support content integrity detection #1791, and should be kept in line with this.
Tests
- Unit, output: passing, failing and cancelled checks in text, JSON and template; each failure class; empty lists; report on standard output and error on standard error.
- Unit, tags: shared layer that is intact, corrupt, missing or could not be checked, with fetch counts; tags with the same digest; one tag that does not resolve; digest in a list; comma in a
--oci-layout-pathreference. - Unit, progress: mismatch after a full read; failure before any read; cancellation does not hang or show a check mark; more nodes than rows; empty index; referrers still listed through the original target.
- E2E: multiple tags;
--format jsonwith a non-zero exit code and valid JSON on standard output.
Related code
cmd/oras/root/pull.go,cmd/oras/internal/option/format.go: format optionscmd/oras/internal/display/handler.go;metadata/model,metadata/json,metadata/template: handler patternscmd/oras/root/backup.go:resolveTags,parseArtifactReferencescmd/oras/internal/option/target.go: reference parsingcmd/oras/internal/display/status/track:target.go,reader.gocmd/oras/internal/display/status/progress:manager.go,messenger.go,status.gointernal/progress/tracker.go:Fail,Done,TrackReaderdocs/proposals/formatted-output.md- oras-go v3.0.0:
verify.go(VerifiedSet,PreVerify,PostVerify)
Why is this needed for ORAS?
Periodic pipelines that check the images in a production repository need results that scripts can read and should not download shared layers repeatedly. Interactive users need progress for large artifacts.
Are you willing to submit PRs to contribute to this feature?
- Yes, I am willing to implement it.
Activity
VanshajPoonia commentedon Nov 29, 2026
I'd like to take part 1, the formatted output (
--format jsonand--format go-template). Plan:metadata/modelwith the proposed schema, and JSON, template and text handlers withSetTypesas inpull.completeandokfalse.Parts 2 and 3 stay open for others, or I can follow with them once part 1 lands.