Closed FeynmanZhou closed 2 months ago
I want to use oras command to only see the layers in JSON format, but it returns the result as follows which looks not friendly to users:
$ oras manifest fetch ghcr.io/deislabs/ratify/notary-image:signed --format {{.Content.layers}} [map[digest:sha256:2408cc74d12b6cd092bb8b516ba7d5e290f485d3eb9672efc00f0583730179e8 mediaType:application/vnd.docker.image.rootfs.diff.tar.gzip size:2.798889e+06] map[digest:sha256:89b865d5710c99cddea45ece6dec6e01a7fea6fc62ce28f667fb7bf26b124b82 mediaType:application/vnd.docker.image.rootfs.diff.tar.gzip size:165] map[digest:sha256:2558cbd97e0483e3bd0c66a3f03f471949c2a6c2fcb5d48a8ca577f22f1653fa mediaType:application/vnd.docker.image.rootfs.diff.tar.gzip size:110]]
If I use --pretty to prettify the JSON output, it doesn't work:
--pretty
oras manifest fetch ghcr.io/deislabs/ratify/notary-image:signed --format {{.Content.layers}} --pretty [map[digest:sha256:2408cc74d12b6cd092bb8b516ba7d5e290f485d3eb9672efc00f0583730179e8 mediaType:application/vnd.docker.image.rootfs.diff.tar.gzip size:2.798889e+06] map[digest:sha256:89b865d5710c99cddea45ece6dec6e01a7fea6fc62ce28f667fb7bf26b124b82 mediaType:application/vnd.docker.image.rootfs.diff.tar.gzip size:165] map[digest:sha256:2558cbd97e0483e3bd0c66a3f03f471949c2a6c2fcb5d48a8ca577f22f1653fa mediaType:application/vnd.docker.image.rootfs.diff.tar.gzip
Show the layers in prettified JSON output:
$ oras manifest fetch ghcr.io/deislabs/ratify/notary-image:signed --format {{.Content.layers}} --pretty [ { "digest": "sha256:2408cc74d12b6cd092bb8b516ba7d5e290f485d3eb9672efc00f0583730179e8", "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "size": 2798889 }, { "digest": "sha256:89b865d5710c99cddea45ece6dec6e01a7fea6fc62ce28f667fb7bf26b124b82", "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "size": 165 }, { "digest": "sha256:2558cbd97e0483e3bd0c66a3f03f471949c2a6c2fcb5d48a8ca577f22f1653fa", "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "size": 110 } ]
See above
Download it with the following steps:
VERSION="1.2.0-manifest-fetch" curl -LO " [https://github.com/qweeah/oras/releases/download/v${VERSION}/oras_${VERSION}_linux_amd64.tar.gz"](https://github.com/qweeah/oras/releases/download/v$%7BVERSION%7D/oras_$%7BVERSION%7D_linux_amd64.tar.gz%22) mkdir -p oras-install/ tar -zxf oras_${VERSION}_*.tar.gz -C oras-install/ rm -rf oras_${VERSION}_*.tar.gz
Ubuntu 22.06
This is expected, you need to use default spring function to convert it to json, e.g.
> oras manifest fetch ghcr.io/deislabs/ratify/notary-image:signed --format "{{toPrettyJson .content.layers}}"
What happened in your environment?
I want to use oras command to only see the layers in JSON format, but it returns the result as follows which looks not friendly to users:
If I use
--pretty
to prettify the JSON output, it doesn't work:What did you expect to happen?
Show the layers in prettified JSON output:
How can we reproduce it?
See above
What is the version of your ORAS CLI?
Download it with the following steps:
What is your OS environment?
Ubuntu 22.06
Are you willing to submit PRs to fix it?