oras-py
oras-py copied to clipboard
Image Index support
As of 0.1.25 it doesn't appear to me this supports Image Indexes.
The lift looks small - maybe as little as adding a media type to defaults.py, a schemas.py definition, and minor work to support it in the Registry object
Sample code might be
class Registry(oras.provider.Registry):
"""
Oras registry with support for image indexes.
"""
@decorator.ensure_container
def get_image_index(self, container, allowed_media_type=None):
"""
Get an image index as a manifest.
This is basically Registry.get_manifest with the following changes
- different default allowed_media_type
- no JSON schema validation
"""
if not allowed_media_type:
default_image_index_media_type = "application/vnd.oci.image.index.v1+json" # TODO: need this in defaults.py
allowed_media_type = [default_image_index_media_type]
headers = {"Accept": ";".join(allowed_media_type)}
manifest_url = f"{self.prefix}://{container.manifest_url()}"
response = self.do_request(manifest_url, "GET", headers=headers)
self._check_200_response(response)
manifest = response.json()
# TODO: jsonschema.validate(manifest, schema=...)
return manifest
If there's interest please let me know and I can put in a PR. In that case I ask if a new method like get_image_index
is desired or if something else would be preferred.
In any case, thank you for the project!
Perhaps under examples https://github.com/oras-project/oras-py/tree/main/examples would suffice? Can you give me the use case of doing this?
My use case is downloading an image index, selecting a platform-compatible manifest, and then following that to ultimately download a platform-specific artifact.
That would be a great (full) example script if you are up for it!