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

Fix various with image pushes. #22

Merged
merged 3 commits into from
Feb 14, 2022
Merged

Fix various with image pushes. #22

merged 3 commits into from
Feb 14, 2022

Conversation

tofay
Copy link
Contributor

@tofay tofay commented Feb 3, 2022

I've been trying to use this crate to pull images from one registry and push them to another - I've fixed a few issues I encountered, and added a test for roundtrip pull/pushing an image with multiple layers.

The existing push doesn't work for images with multiple layers because the code conflates chunks and layers. e.g it starts a push session for ImageData, then proceeds to push all the layers as chunks in a single blob.
I've updated this to have a push session per layer, per the spec.

The push response for Client::push similarly doesn't return an image_url, as that
doesn't make sense for images with multiple layers.

The ImageData struct no longer produces a digest from the contained
layers as digests are applicable to content blobs, or manifests.

If the manifest being pushed has a media type, then use that instead of the OCI V1 media type. (If the manifest is not the OCI v1 media type then the registry will reject the manifest push.)

Manifests are canonicalized to canonical json per
https://github.com/opencontainers/image-spec/blob/main/considerations.md?plain=1#L18.
I've also updated the manifest structs to not serialize unspecified optional fields as null. That complies with the json schemas in the image-spec repo. The spec wasn't clear on the behaviour here, so I raised opencontainers/image-spec#894. I probably should have done that in a separate PR - happy to drop it from this and submit in a new one if that's contravertial.

Pushing images with multiple layers now works, because the client
has an upload session per layer, rather than an upload session per
blob. The push response simlarly doesn't return an image_url, as that
doesn't make sense for images with multiple layers.

Manifests are canonicalized per
https://github.com/opencontainers/image-spec/blob/main/considerations.md?plain=1#L18

The ImageData struct no longer produces a digest from the contained
layers as digests are applicable to content blobs, or manifests.

Signed-off-by: Tom Fay <tomfay@microsoft.com>
src/client.rs Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
Signed-off-by: Tom Fay <tomfay@microsoft.com>
Copy link
Contributor

@flavio flavio left a comment

Choose a reason for hiding this comment

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

Looks good to me, I left some minor comments

src/client.rs Show resolved Hide resolved
src/client.rs Outdated Show resolved Hide resolved
src/client.rs Show resolved Hide resolved
Signed-off-by: Tom Fay <tomfay@microsoft.com>
Copy link
Contributor

@flavio flavio left a comment

Choose a reason for hiding this comment

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

Thanks for having addressed the feedback

@flavio flavio merged commit 20a5363 into oras-project:main Feb 14, 2022
@cardil
Copy link

cardil commented Feb 15, 2022

Looking forward for release with this patch. I'm hitting similar issues.

@flavio
Copy link
Contributor

flavio commented Feb 15, 2022

@cardil 👍 I personally would like to go through a bunch of open PR, so that we break the API fewer times :)

thomastaylor312 pushed a commit that referenced this pull request Mar 2, 2023
Fix various with image pushes.
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