|
2 | 2 | import tarfile |
3 | 3 |
|
4 | 4 | import oras.client |
5 | | -import oras.provider |
6 | 5 | from oras.logger import setup_logger |
7 | 6 |
|
8 | | - |
9 | 7 | setup_logger(quiet=True, debug=False) |
10 | 8 |
|
11 | 9 |
|
12 | | -class VdbDistributionRegistry(oras.provider.Registry): |
13 | | - """ |
14 | | - We override the default registry to make things compatible with ghcr. Without this, the below error is thrown. |
15 | | -
|
16 | | - jsonschema.exceptions.ValidationError: Additional properties are not allowed ('artifactType' was unexpected) |
17 | | - """ |
18 | | - |
19 | | - def get_manifest(self, container, allowed_media_type=None, refresh_headers=True): |
20 | | - """ |
21 | | - Retrieve a manifest for a package. |
22 | | -
|
23 | | - :param container: parsed container URI |
24 | | - :type container: oras.container.Container or str |
25 | | - :param allowed_media_type: one or more allowed media types |
26 | | - :type allowed_media_type: str |
27 | | - """ |
28 | | - if not allowed_media_type: |
29 | | - allowed_media_type = [oras.defaults.default_manifest_media_type] |
30 | | - headers = {"Accept": ";".join(allowed_media_type)} |
31 | | - |
32 | | - get_manifest = f"{self.prefix}://{container.manifest_url()}" # type: ignore |
33 | | - response = self.do_request(get_manifest, "GET", headers=headers) |
34 | | - self._check_200_response(response) |
35 | | - manifest = response.json() |
36 | | - return manifest |
37 | | - |
38 | | - |
39 | 10 | def download_image(target, outdir): |
40 | 11 | """ |
41 | 12 | Method to download vdb files from a oci registry |
42 | 13 | """ |
43 | | - oras_client = oras.client.OrasClient(registry=VdbDistributionRegistry()) |
| 14 | + oras_client = oras.client.OrasClient() |
44 | 15 | paths_list = oras_client.pull( |
45 | 16 | target=target, |
46 | 17 | outdir=outdir, |
|
0 commit comments