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

build: refactor reference parsing for oci image layouts #1456

Merged
merged 2 commits into from
Jan 6, 2023

Conversation

jedevc
Copy link
Collaborator

@jedevc jedevc commented Dec 7, 2022

⬆️ Follow up to #1173.

We allow any valid image reference format for the oci-layout, not just limiting to name@digest, we additionally allow images of the form name:tag@digest now.

The name of the reference is used to find the local directory to lookup the store in, while the tag and digest are attached to a random identity to generate the dummy reference sent to the oci-layout context.

This separation of the target to replace and the value to replace it with ensures that any tag or digest set in the client is properly sent across to the server. The tag, while not relevant now, may become relevant at some point in the future for the server, so we can should send it across for now.

Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the handwritten parsing and not just using the reference library?

@jedevc
Copy link
Collaborator Author

jedevc commented Dec 9, 2022

Why the handwritten parsing and not just using the reference library?

From the early implementation in #1173 (comment): need to add "dummy.io", because reference.Parse*() funcs require we do not start with a '/'. The reference library doesn't allow a valid path as the name, so we can only include OCI images in the current directory 😅

Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should still do the validation of digest on client side. If it is a tag, we should resolve it on the client side as well.

Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requiring digest is very painful for the user. We should just support directory (optional tag), and find the digest on client side if possible.

@jedevc jedevc force-pushed the oci-layout-reference-parsing branch from 77ac125 to 7d7f1a4 Compare December 14, 2022 15:53
@jedevc
Copy link
Collaborator Author

jedevc commented Dec 14, 2022

Have added logic for doing some basic tag resolution as well as some digest verification. Unfortunately, the hand-written parsing is still required.

build/build.go Outdated Show resolved Hide resolved
We allow any valid image reference format for the oci-layout, not just
limiting to name@digest, we additionally allow images of the form
name:tag@digest now.

The name of the reference is used to find the local directory to lookup
the store in, while the tag and digest are attached to a random identity
to generate the dummy reference sent to the oci-layout context.

This separation of the target to replace and the value to replace it
with ensures that any tag or digest set in the client is properly sent
across to the server. The tag is used when a digest was not specified,
and it is resolved in the context of the local directory before being
sent, using the same helpers as we use for the local cache expoter.

Signed-off-by: Justin Chadwell <me@jedevc.com>
@jedevc jedevc force-pushed the oci-layout-reference-parsing branch from 7d7f1a4 to 70682b0 Compare December 14, 2022 16:53
@jedevc jedevc added this to the v0.10.0 milestone Jan 5, 2023
@jedevc
Copy link
Collaborator Author

jedevc commented Jan 5, 2023

cc @deitch (thought you might be interested in this one)

@deitch
Copy link
Contributor

deitch commented Jan 5, 2023

Thanks for cc'ing me @jedevc . I am interested.

I always have to remind myself of the current behaviour, just to evaluate what this does. 😁

The prior was oci-layout:///path/to/image@sha256:<hash>. It would then look in /path/to/image/blobs/sha256/<hash> to find the manifest/index.

This changes it to also support oci-layout:///path/to/image:tag, so it can read index.json for the tag, and then find the manifest/index from there? That is much nicer.

Based on the code, it looks like any form will work, e.g. I have seen many that "override" the index.json to include many images, not just many tags, and I think that would work here?

@deitch
Copy link
Contributor

deitch commented Jan 5, 2023

Should we add some examples to the docs/README for it?

Signed-off-by: Justin Chadwell <me@jedevc.com>
@jedevc
Copy link
Collaborator Author

jedevc commented Jan 5, 2023

Ah, yup, have updated the reference docs for it no, to explain the new tags behavior 👍 It's a lot neater now that we don't have to explain about requiring a digest in the name 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants