Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add get_digest(container) method on provider.Registry #143

Open
hanikesn opened this issue Jun 10, 2024 · 1 comment
Open

Add get_digest(container) method on provider.Registry #143

hanikesn opened this issue Jun 10, 2024 · 1 comment

Comments

@hanikesn
Copy link

It can often be quite useful to resolve a tag to the digest where an artifact is stored in the registry. To solve this I duplicated the code of Registry.get_manifest and compute the hash client side:

    @decorator.ensure_container
    def get_digest(self, container):
        self.load_configs(container)
        allowed_media_type = [defaults.default_manifest_media_type]
        headers = {"Accept": ";".join(allowed_media_type)}
        headers.update(self.headers)
        get_manifest = f"{self.prefix}://{container.manifest_url()}"  # type: ignore
        response = self.do_request(get_manifest, "GET", headers=headers)
        self._check_200_response(response)
        return f"sha256:{hashlib.sha256(response.content).hexdigest()}"
@vsoch
Copy link
Contributor

vsoch commented Jun 10, 2024

This would be good to add to the repository, perhaps as an example or helper script?

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

No branches or pull requests

2 participants