-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Oras commands like attach, discover, and pull support an option to format output as JSON #638
Comments
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. |
Thanks @plooploops for this feature request. Can you elaborate on the scenarios of programmatically checking artifact status for oras Below are some minimal information needed in the JSON output in my mind: |
For oras discoverThanks @qweeah, you're right that 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:
And 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. For oras pullThe fields you had mentioned make sense, and it would also be helpful to get the downloaded Suppose you make the following call:
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 attachThe fields you had mentioned make sense, and it would also be helpful to get the uploaded Suppose you make the following call:
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. |
@plooploops Thanks for the clarification. Here are some comments:
/cc @FeynmanZhou for UX clarification and @shizhMSFT for planning. |
Please use |
Good point. Updated inline.
We don't need both. |
Updated version per comments: For oras discoverFor example, suppose you make the call:
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. For oras pullFor Suppose you make the following call:
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 attachFor Suppose you make the following call:
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. |
@plooploops This version looks good to me. One small thing to add: |
@qweeah Sounds good. Updated the version here (and will copy it to the top of the post). Updated version per comments: For oras discoverFor example, suppose you make the call:
And 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. For oras pullFor Suppose you make the following call:
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 attachFor Suppose you make the following call:
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
} |
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 |
I'm interested in simplifying @sajayantony. Which spec are you referring to in this case? Using |
I was referring to about only removing the http(s) prefix. All other fields seem reasonable. /cc @shizhMSFT for any further input. |
Sounds good @sajayantony. @qweeah are you open to removing the For example, when you call {
"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
} |
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 fetch
|
@plooploops Sounds good if it helps automation.
@sajayantony Worth to mention that be above use case is already supported via
|
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. |
It is bit weird to have
Generally speaking, this proposal and #497 are proposing the same thing: It is better to let the How about 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 |
@sajayantony @qweeah - I've updated the top comment to reflect removing the scheme @shizhMSFT if there's an output formatting option for As you mentioned, oras pull <myacr>.azurecr.io/my/repo/image@sha256:somehash -o json --allow-path-traversal
Downloading differentHash C:\path\to\output\payload.json
Downloaded differentHash C:\path\to\output\payload.json
Pulled <myacr>.azurecr.io/my/repo/image@sha256:somehash
Digest: sha256:somehash If you can format the output that you get from stdout to After looking through the metadata file example from #497, it's possible to parse the metadata file to find the relevant fields like |
@sajayantony @qweeah @shizhMSFT Here's a hackmd to cover what's been included so far: https://hackmd.io/@plooploops/SkJn5qONs |
The proposal looks good and now I understand the scenario that you are requesting. For the tag name, there is already a flag |
The This proposal is to change the CLI display to the stdout. How about naming this kind of feature as $ oras pull example.contoso.com/myapp:v1 --output Downloads/myapp --display json
{
"digest": "sha256:01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b",
"mediaType": "application/vnd.oci.artifact.manifest.v1+json",
"artifactType": "application/vnd.myapp",
"reference" : "example.contoso.com/myapp@sha256:01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b",
"files" : [
"Downloads/myapp/artifact.json",
"Downloads/myapp/app.tar"
],
"size": 532
}
$ ls Downloads/myapp
artifact.json
app.tar |
@FeynmanZhou we could use the However, @shizhMSFT brought up an interesting alternative in keeping the In the hackmd I was using the 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. |
Reviving this back up for 1.2.0. |
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
, andpull
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:
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
, andfiles
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:
For oras attach
For
oras attach
, it would also be helpful to get the uploadedartifactDigest
,reference
, andfiles
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:
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?
The text was updated successfully, but these errors were encountered: