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

Get digest before push #161

Closed
griffin opened this issue May 13, 2020 · 7 comments
Closed

Get digest before push #161

griffin opened this issue May 13, 2020 · 7 comments
Labels
duplicate This issue or pull request already exists enhancement New feature or request
Milestone

Comments

@griffin
Copy link

griffin commented May 13, 2020

👋
I wanted to see if the project was open to adding a cli command and a library function to get the digest of an artifact before pushing. We have some bazel rules that use ORAS to create custom artifacts and then output the digest, but we have have to do this in a reproducible way without network access. Bazel's rules_docker does something similar to this.

It seems as though I could adapt some of the code here to do this, but I wanted to get a feel for this feature before I started implementation.

@SteveLasker
Copy link
Contributor

Interesting. @shizhMSFT, what do you think?

@griffin
Copy link
Author

griffin commented Jun 12, 2020

I've written an internal patch to do this, extending the push command with a --dry-run flag.

A better design may be introducing a primitive digest command, but it requires abstracting part of the push command as it has a lot of the same logic. I would like to confirm a plan before undertaking any larger work.

@SteveLasker
Copy link
Contributor

We've had a few recent conversations about how we might achieve this. For example, the notary v2 efforts require a manifest to sign, which requires a digest.
I think there's an interesting set of factoring questions here
Should ORAS include

  • digest generation libraries?
  • manifest creation, without having to push to a registry first?

Open to discussion from other maintainers (@jdolitsky, @shizhMSFT, @jzelinskie, @vbatts, @sajayantony)

@shizhMSFT
Copy link
Contributor

A dry run for manifest generation is interesting. Once, we have manifest, we can compute the manifest digest and sign it using notary v2 later.

@SteveLasker
Copy link
Contributor

@griffin - you might want to checkout https://github.com/deislabs/oras/tree/prototype-2
@shizhMSFT added the --dry-run support, along with --export-manifest as part of the Notary v2 prototype work.

If we like, we can promote it up to main, but I do want to give credit for your suggestion.

oras push localhost:5000/foo:bar \
  --dry-run \
  --export-manifest manifest.json \
  sbom.json

cat manifest.json

Output:

{
  "schemaVersion": 2,
  "config": {
    "mediaType": "application/vnd.unknown.config.v1+json",
    "digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
    "size": 2
  },
  "layers": [
    {
      "mediaType": "application/vnd.oci.image.layer.v1.tar",
      "digest": "sha256:b0a764ebc678d8614c9c05e2fef857b9bf0673ed3e66a6cec0a14540942e7ad4",
      "size": 101,
      "annotations": {
        "org.opencontainers.image.title": "sbom.json"
      }
    }
  ]
}

And, new experimental reference artifact support

oras push localhost:5000/foo:bar \
  --artifact-type application/x.sample.doc.v0 \
  --dry-run \
  --export-manifest manifest.json \
  sbom.json

cat manifest.json

Output:

{
  "schemaVersion": 2,
  "mediaType": "application/vnd.oci.artifact.manifest.v1+json",
  "artifactType": "application/x.sample.doc.v0",
  "blobs": [
    {
      "mediaType": "application/vnd.oci.image.layer.v1.tar",
      "digest": "sha256:b0a764ebc678d8614c9c05e2fef857b9bf0673ed3e66a6cec0a14540942e7ad4",
      "size": 101,
      "annotations": {
        "org.opencontainers.image.title": "sbom.json"
      }
    }
  ],
  "manifests": []
}

@sajayantony sajayantony added the enhancement New feature or request label Sep 28, 2021
@shizhMSFT shizhMSFT added this to the future milestone May 7, 2022
@shizhMSFT
Copy link
Contributor

shizhMSFT commented Aug 15, 2022

This issue can be resolved once #378 is resolved.

That is, push to an OCI layout, and then get whatever we want to do further process. Finally, do oras copy from the OCI layout to the remote registry.

@yizha1 yizha1 modified the milestones: future, v1.0.0 Aug 31, 2022
@shizhMSFT shizhMSFT added the duplicate This issue or pull request already exists label Nov 2, 2022
@qweeah
Copy link
Contributor

qweeah commented Jan 20, 2023

Closing as it's covered via oras push/attach --oci-layout in main branch.

@griffin You may use a local folder test to stage the manfiest before pushing it to a remote registry. Try below commands:

oras push --oci-layout ./test:v1  foo bar # pack file `foo` and `bar` into an artifact tagged with `v1`
oras manifest fetch --oci-layout ./test:v1 --descriptor # fetch the descriptor of the generated manifest (digest included)
oras copy --from-oci-layout ./test:v1 <your.registry>/<repo>:v1 # uploading the artifact to remote registry

You need to build from main branch. This feature will be included in oras 1.0.0-rc.1 release planned for end of Jan 2023.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists enhancement New feature or request
Projects
No open projects
Status: Done
Development

No branches or pull requests

6 participants