Skip to content
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

Output the descriptor of pushed artifact by oras push #497

Closed
shizhMSFT opened this issue Aug 15, 2022 · 11 comments
Closed

Output the descriptor of pushed artifact by oras push #497

shizhMSFT opened this issue Aug 15, 2022 · 11 comments
Labels
enhancement New feature or request question Further information is requested
Milestone

Comments

@shizhMSFT
Copy link
Contributor

shizhMSFT commented Aug 15, 2022

The oras push command should have an option like --export-manifest-descriptor to write the descriptor of pushed artifact to a file so that the descriptor can be used for other processes like signing.

@shizhMSFT shizhMSFT added this to the v0.15.0 milestone Aug 15, 2022
@shizhMSFT
Copy link
Contributor Author

This can also be done by --export-manifest but more simplified.

@FeynmanZhou @yizha1 Any comments?

@sajayantony
Copy link
Contributor

Could we consider aligning this with commands like manifest fetch ?
Could you also describe what is the advantage of outputting these to a file instead of stdout and maybe just applying jq on top.

For e.g. docker manifest inspect has a --verbose option that outputs a different format with more fields -

$ docker manifest inspect --verbose docker.io/library/nginx@sha256:...
{
        "Ref": "docker.io/library/nginx@sha256:....",
        "Descriptor": {
                "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
                "digest": "sha256:5c134d3a19dc5fb01f4e7df9c36e3c054153e661b4bd3472858940894569d829",
                "size": 1570,
                "platform": {
                        "architecture": "mips64le",
                        "os": "linux"
                }
        },

this would just enable scripts to easily compose

docker manifest inspect --verbose {ref} | jq '.Descriptor' 

@shizhMSFT
Copy link
Contributor Author

That's a different thing. The idea was to export the manifest or the manifest descriptor without fetching anything from the remote registry, which may not be trusted.

@shizhMSFT
Copy link
Contributor Author

shizhMSFT commented Aug 15, 2022

This also can be resolved by resolving #378 and then oras manfiest fetch --descriptor. However, doing --export-manifest or --export-manifest-descriptor is more efficient.

@shizhMSFT
Copy link
Contributor Author

I was expecting to have something similar to --metadata-file.

@shizhMSFT
Copy link
Contributor Author

By running the following commands, we will get a metadata.json file.

docker buildx create --use
docker buildx build --load --metadata-file metadata.json https://github.com/oras-project/oras.git#main

The content of metadata.json is

{
  "containerimage.buildinfo": {
    "frontend": "dockerfile.v0",
    "attrs": {
      "context": "https://github.com/oras-project/oras.git#main",
      "filename": "Dockerfile"
    },
    "sources": [
      {
        "type": "docker-image",
        "ref": "docker.io/library/alpine:3.15.4",
        "pin": "sha256:4edbd2beb5f78b1014028f4fbb99f3237d9561100b6881aabbf5acce2c4f9454"
      },
      {
        "type": "docker-image",
        "ref": "docker.io/library/golang:1.19.0-alpine",
        "pin": "sha256:0eb08c89ab1b0c638a9fe2780f7ae3ab18f6ecda2c76b908e09eb8073912045d"
      },
      {
        "type": "git",
        "ref": "https://github.com/oras-project/oras.git#main",
        "pin": "ee74ae205421c1183e7fb3fb90842a9cbf1ed625"
      }
    ]
  },
  "containerimage.config.digest": "sha256:e38d4a0954edda42d8d0a78c7e683385939384e8a2295103f79228b9a13704aa",
  "containerimage.descriptor": {
    "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
    "digest": "sha256:1fad23b0f5bc32605ccc952263c6ecfa6dbca0398347cda7c5b50beed7abeca8",
    "size": 1363,
    "annotations": {
      "org.opencontainers.image.created": "2022-08-16T08:41:47Z"
    }
  },
  "containerimage.digest": "sha256:1fad23b0f5bc32605ccc952263c6ecfa6dbca0398347cda7c5b50beed7abeca8"
}

@FeynmanZhou
Copy link
Member

FeynmanZhou commented Aug 16, 2022

Hi @shizhMSFT @sajayantony ,

From my understanding, this feature is intended to export the descriptor of an artifact to a file instead of fetching something from a remote registry. ORAS has a flag of --export-manifest so using --export-manifest-descriptor looks more specific and intuitive to me.

Users can also use this feature to simplify the offline signing process for Notation since they can sign the descriptor from a local file instead of interacting with an OCI registry.

@FeynmanZhou FeynmanZhou added the enhancement New feature or request label Aug 17, 2022
@shizhMSFT
Copy link
Contributor Author

@jasminetMSFT Could you help follow up?

@jasminetMSFT
Copy link
Contributor

@shizhMSFT No problem, I will look into this.

@shizhMSFT
Copy link
Contributor Author

The user requirement needs to be verified by the local signing functionality of notation (Notary V2).

@shizhMSFT
Copy link
Contributor Author

Closing this issue as the original requirement is achievable by the OCI-layout support. Precisely,

  1. oras push --oci-layout to push artifacts to an OCI Layout folder.
  2. oras manifest fetch --descriptor --oci-layout to inspect the manifest.
  3. Make changes to the content of the OCI Layout folder if needed.
  4. oras copy --from-oci-layout to copy the artifacts to the remote.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants