Repository navigation
Description
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
Projects
- StatusShow more project fieldsNo status
Activity
sajayantony commentedon Oct 10, 2022
I would also hope that the json output could contain more scriptable values like fully qualified references so that clients don’t have to join strings.
qweeah commentedon Oct 11, 2022
Thanks @plooploops for this feature request. Can you elaborate on the scenarios of programmatically checking artifact status for oras
attach,discoverandpullrepectively?Below are some minimal information needed in the JSON output in my mind:
oras discover:
digest,media type,size,artifact type(already supportted with-o jsonflag) andURLoras pull:
digest,media typeandsizeof the pulled artifact manifestoras attach:
digest,media type,sizeandURLof the newly created artifactplooploops commentedon Oct 12, 2022
For oras discover
Thanks @qweeah, you're right that
oras discoversupports the-o jsonflag!It would be helpful to include the URL as you had mentioned, I'm assuming in this case it would be for the artifact itself?
For example, suppose you make the call:
oras discover <myacr>.azurecr.io/my/repo:tag -o jsonAnd then you would get a JSON output like the following:
{ "referrers": [ { "digest": "sha256:someHash", "mediaType": "someType", "artifactType": "someArtifactType", "artifactUrl" : "<myacr>.azurecr.io/my/repo@sha256:someHash", "size": sizeInBytes }, ] }This would allow you to pull in the artifact (e.g.
oras pull <artifactUrl value>.For oras pull
The fields you had mentioned make sense, and it would also be helpful to get the downloaded
artifactType,artifactUrl, andartifactFilepathtoo.Suppose you make the following call:
oras pull <artifactUrl value>And then you would get a JSON output like the following:
{ "digest": "sha256:someHash", "mediaType": "someType", "artifactType": "someArtifactType", "artifactUrl" : "<myacr>.azurecr.io/my/repo@sha256:someHash", "artifactFilepath" : "path/to/my/downloaded/artifact.json", "size": sizeInBytes }For oras attach
The fields you had mentioned make sense, and it would also be helpful to get the uploaded
artifactDigest,artifactUrl, andartifactFilePath.Suppose you make the following call:
oras attach "<myacr>.azurecr.io/my/repo:tag" --artifact-type "someArtifactType" <path/to/some/artifact>:<type>And then you would get a JSON output like the following:
{ "digest": "sha256:someHash", "mediaType": "someType", "artifactType": "someArtifactType", "artifactDigest" : "sha256:someOtherHash", "artifactUrl" : "<myacr>.azurecr.io/my/repo@sha256:someHash", "artifactFilepath" : "path/to/my/uploaded/artifact.json", "size": sizeInBytes }If you think these make sense, I can pull the notes to the top post.
qweeah commentedon Oct 13, 2022
@plooploops Thanks for the clarification. Here are some comments:
artifactUrl: I suggest to name it toreferencesince both OCI image and OCI artifact could have this field. And as you have described, this field specifies a URI from which this object MAY be downloaded, conforming to RFC 3986 with a scheme as defined in RFC 7230. Also user won't need this field in the result oforas pullsince it's in the CLI argument.artifactFilepath: I suggest to usefileswith an array type since more than one file might be processed.oras pullneed this field. Howeveroras attachdoesn't because the blob file paths are specified by end users via the CLI arguments.artifactDigest: This field is duplicated todigestfield and only having one fielddigestwould be enough./cc @FeynmanZhou for UX clarification and @shizhMSFT for planning.
sajayantony commentedon Oct 13, 2022
Please use
referencesince thats has a well know definition in OCI. I’m curious why do we need to digest and artifactDigest?qweeah commentedon Oct 13, 2022
Good point. Updated inline.
We don't need both.
digestonly would be enough.plooploops commentedon Oct 14, 2022
Updated version per comments:
For oras discover
For example, suppose you make the call:
oras discover <myacr>.azurecr.io/my/repo:tag -o jsonAnd 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 downloadedartifactType,reference, andfilesalong with the other fields described in the below sample output.Suppose you make the following call:
oras pull <reference value>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 attaach, it would also be helpful to get the uploadedartifactDigest,reference, andfilesalong 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>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 }Again, open for comments (and thank you for the input already @sajayantony and @qweeah!)
If we think this covers a good first version, then I'll pull it up to the top of the post.
qweeah commentedon Oct 16, 2022
@plooploops This version looks good to me. One small thing to add:
referenceshould contain scheme, e.g.http[s]://<myacr>.azurecr.io/my/repo@sha256:someHashplooploops commentedon Oct 24, 2022
@qweeah Sounds good. Updated the version here (and will copy it to the top of the post).
Updated version per comments:
For oras discover
For example, suppose you make the call:
oras discover <myacr>.azurecr.io/my/repo:tag -o jsonAnd then you would get a JSON output like the following:
{ "referrers": [ { "digest": "sha256:someHash", "mediaType": "someType", "artifactType": "someArtifactType", "reference" : "http[s]://<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 downloadedartifactType,reference, andfilesalong with the other fields described in the below sample output.Suppose you make the following call:
oras pull <reference value>And then you would get a JSON output like the following:
{ "digest": "sha256:someHash", "mediaType": "someType", "artifactType": "someArtifactType", "reference" : "http[s]://<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 attaach, it would also be helpful to get the uploadedartifactDigest,reference, andfilesalong 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>And then you would get a JSON output like the following:
{ "digest": "sha256:someHash", "mediaType": "someType", "artifactType": "someArtifactType", "reference" : "<http[s]://<myacr>.azurecr.io/my/repo@sha256:someHash", "files" : [ "path/to/my/uploaded/artifact.json", "path/to/my/other/uploaded/artifact.json" ], "size": sizeInBytes }sajayantony commentedon Oct 24, 2022
The reference doesn’t contain a scheme as per the spec. Also you can’t use that format in most tools and so if you pipe that to say
oras tagthen that wouldn’t work.My vote is to follow the spec and use
fqdn/repo:tag
plooploops commentedon Oct 26, 2022
I'm interested in simplifying @sajayantony. Which spec are you referring to in this case?
Using
"<myacr>.azurecr.io/my/repo@sha256:someHash"instead would make subsequent automation easier, for example, when looking to pull in your manifest withoras manifest fetch.sajayantony commentedon Oct 26, 2022
I was referring to about only removing the http(s) prefix. All other fields seem reasonable. /cc @shizhMSFT for any further input.
plooploops commentedon Oct 26, 2022
Sounds good @sajayantony.
@qweeah are you open to removing the
http(s)part for thereferencefield?For example, when you call
oras attach "<myacr>.azurecr.io/my/repo:tag" --artifact-type "someArtifactType" <path/to/some/artifact>:<type>you would get something like this:{ "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 }sajayantony commentedon Oct 27, 2022
SGTM -
Does this sound like what you had in mind @plooploops
oras attach myreg.azurecr.io/my/repo:tag \ --artifact-type "example/foo" logo.jpg:image/jpg \ -o json \ | jq .reference | xargs -n1 oras manifest fetch1 remaining item
sajayantony commentedon Oct 27, 2022
Ok my example may be bad. But the fact that I can use the fully qualified reference to the next command is still valuable. I don’t have to concat stuff.
shizhMSFT commentedon Oct 27, 2022
It is bit weird to have
--outputfororas pullas we already have that option.Generally speaking, this proposal and #497 are proposing the same thing: It is better to let the
orasCLI to output some metadata so that it can be further processed.How about
--metadata-file? For example,oras attach myreg.azurecr.io/my/repo:tag \ --artifact-type "example/foo" logo.jpg:image/jpg \ --metadata-file <metadata-file-path>The metadata file can be further processed later. Even if there is an error in the middle of
oras attach, you still can get some logs althoughorasis not able to produce the final metadata file.plooploops commentedon Oct 27, 2022
@sajayantony @qweeah - I've updated the top comment to reflect removing the scheme
<http[s]>from thereferencefield. I also added the-o jsonflag as part of the example calls fororas discover,oras pull, andoras attach.@shizhMSFT if there's an output formatting option for
-o jsonor--output jsonthat would let you format your output for stdout fororas discover,oras pull, and fororas attachwould be helpful.As you mentioned,
oras pulldoes have-o jsonbut this will put an output file somewhere, and you would need to parse the message to get the path, and then parse the output file.If you can format the output that you get from stdout to
jsonfororas discover,oras pull, andoras attach, then you can process the response without needing to parse text. For example, Azure CLI commands support multiple output formats, and having differentorascommands implementing an output formatting option would be helpful from an automation standpoint.After looking through the metadata file example from #497, it's possible to parse the metadata file to find the relevant fields like
digestorreference, but is the schema of the metadata file stable? In this case, we'd still be parsing a file.plooploops commentedon Oct 28, 2022
@sajayantony @qweeah @shizhMSFT
Here's a hackmd to cover what's been included so far: https://hackmd.io/@plooploops/SkJn5qONs
FeynmanZhou commentedon Oct 28, 2022
The proposal looks good and now I understand the scenario that you are requesting. For the tag name, there is already a flag
output -oin some commands to export the output to a file. Will it be easy for users to memorize if we use just one--outputflag and provide multiple options (file, JSON, other formats)?shizhMSFT commentedon Oct 28, 2022
The
--outputoption means output file path or output directory in many commands likeoras pull,oras blob fetch,oras manifest fetch, etc..This proposal is to change the CLI display to the stdout. How about naming this kind of feature as
--display. It takes options liketext,json, and eventty,csv,yamlin the future. Let me put them in a single example,plooploops commentedon Oct 28, 2022
@FeynmanZhou we could use the
-oas you had mentioned for different output types likefile,JSON.However, @shizhMSFT brought up an interesting alternative in keeping the
-oand--outputreserved for the file path for output, and then using--display jsonto display the results in JSON to stdout.In the hackmd I was using the
--format jsonoption instead, but I do like the option you had mentioned @shizhMSFT.I updated the hackmd to reflect the proposal (and pull in your example @shizhMSFT) so we can have options for getting files, and for formatting responses to stdout as JSON.
sajayantony commentedon Jul 19, 2023
Reviving this back up for 1.2.0.
Improving the scriptability of oras is important. I think having individual issues for each of these commands would be good to discuss the respective outputs while implementing it. @FeynmanZhou @shizhMSFT