Skip to content

Oras commands like attach, discover, and pull support an option to format output as JSON #638

@plooploops

Description

@plooploops

What is the version of your ORAS CLI

Version: 0.15.0 Go version: go1.19 Git commit: 94abaec Git tree state: clean

What would you like to be added?

An option to format output for commands like attach, discover, and pull as JSON.

Updated version per comments:

For oras discover

For example, suppose you make the call:

oras discover <myacr>.azurecr.io/my/repo:tag -o json

And then you would get a JSON output like the following:

{
  "referrers": [
    {
      "digest": "sha256:someHash",
      "mediaType": "someType",
      "artifactType": "someArtifactType",
      "reference" : "<myacr>.azurecr.io/my/repo@sha256:someHash",
      "size": sizeInBytes
    },
  ]
}

This would allow you to pull in the artifact (e.g. oras pull <reference value>.

For oras pull

For oras pull, it would be helpful to get the downloaded artifactType, reference, and files along with the other fields described in the below sample output.

Suppose you make the following call:

oras pull <reference value> -o json

And then you would get a JSON output like the following:

{
  "digest": "sha256:someHash",
  "mediaType": "someType",
  "artifactType": "someArtifactType",
  "reference" : "<myacr>.azurecr.io/my/repo@sha256:someHash",
  "files" : [
    "path/to/my/downloaded/artifact.json",
    "path/to/another/downloaded/artifact.json"
  ],
  "size": sizeInBytes
}

For oras attach

For oras attach, it would also be helpful to get the uploaded artifactDigest, reference, and files along with the other fields described in the below sample output.

Suppose you make the following call:

oras attach "<myacr>.azurecr.io/my/repo:tag" --artifact-type "someArtifactType" <path/to/some/artifact>:<type> -o json

And then you would get a JSON output like the following:

{
  "digest": "sha256:someHash",
  "mediaType": "someType",
  "artifactType": "someArtifactType",
  "reference" : "<myacr>.azurecr.io/my/repo@sha256:someHash",
  "files" :  [
    "path/to/my/uploaded/artifact.json",
    "path/to/my/other/uploaded/artifact.json"
  ],
  "size": sizeInBytes
}

Why is this needed for ORAS?

This would be helpful for programmatically checking artifact status vs. parsing text lines (which could change depending on environment).

Are you willing to submit PRs to contribute to this feature?

  • Yes, I am willing to implement it.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions