Open linshokaku opened 1 year ago
If manifest_config is not specified when pushing by oras-py, the implementation currently treats manifest_config as a completely empty string. https://github.com/oras-project/oras-py/blob/02c5bdacb54b5d7d6c152fcdbc0e11cf69b4900f/oras/oci.py#L130-L136
I was using google artifact registry and confirmed that push fails if manifest_config is an empty string.
The current workaround (or maybe this is the right way) is to create a file with only "{}" and read that file to successfully execute the push.
If manifest_config was not specified, why not change it so that the contents of manifest_config are treated as "{}"?
import oras.client import oras.logger from pathlib import Path from tempfile import TemporaryDirectory import os import json oras.logger.setup_logger(debug=True, quiet=False) pwd = Path(__file__).parent.resolve() client = oras.client.OrasClient() client.login(username="oauth2accesstoken", password="password") with TemporaryDirectory() as tmp: config_path = os.path.join(tmp, "config.json") with open(config_path, "w") as f: json.dump({}, f) res = client.push(files=[str(pwd / "hoge.txt")], target="asia-northeast1-docker.pkg.dev/example-repository/tmp/oras-test:v2", manifest_config=config_path) print("sucess push with config file") res = client.push(files=[str(pwd / "hoge.txt")], target="asia-northeast1-docker.pkg.dev/example-repository/tmp/oras-test:v2") print("success push")
Preparing layer {'mediaType': 'application/vnd.oci.image.layer.v1.tar', 'size': 13, 'digest': 'sha256:8f8ad85c91228f6b241b95ecca626a4e9701d7c072ca0c6c001677d797a4af02', 'annotations': {'org.opencontainers.image.title': 'hoge.txt'}} Service: asia-northeast1-docker.pkg.dev Scope: repository:example-repository/tmp/oras-test:pull,push Preparing config {'mediaType': 'application/vnd.unknown.config.v1+json', 'size': 2, 'digest': 'sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a'} Service: asia-northeast1-docker.pkg.dev Scope: repository:example-repository/tmp/oras-test:pull,push Service: asia-northeast1-docker.pkg.dev Scope: repository:example-repository/tmp/oras-test:pull,push Successfully pushed asia-northeast1-docker.pkg.dev/example-repository/tmp/oras-test:v2 sucess push with config file Preparing layer {'mediaType': 'application/vnd.oci.image.layer.v1.tar', 'size': 13, 'digest': 'sha256:8f8ad85c91228f6b241b95ecca626a4e9701d7c072ca0c6c001677d797a4af02', 'annotations': {'org.opencontainers.image.title': 'hoge.txt'}} Service: asia-northeast1-docker.pkg.dev Scope: repository:example-repository/tmp/oras-test:pull,push Preparing config {'mediaType': 'application/vnd.unknown.config.v1+json', 'size': 0, 'digest': 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'} Service: asia-northeast1-docker.pkg.dev Scope: repository:example-repository/tmp/oras-test:pull,push Service: asia-northeast1-docker.pkg.dev Scope: repository:example-repository/tmp/oras-test:pull,push Trying with provided Basic Authorization... failed to read config blob: sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Traceback (most recent call last): File "/Users/linsho/repos/oras-py/tmp/./tmp_log.py", line 22, in <module> res = client.push(files=[str(pwd / "hoge.txt")], target="asia-northeast1-docker.pkg.dev/example-repository/tmp/oras-test:v2") File "/Users/linsho/repos/oras-py/tmp/venv/lib/python3.10/site-packages/oras/client.py", line 132, in push return self.remote.push(*args, **kwargs) File "/Users/linsho/repos/oras-py/tmp/venv/lib/python3.10/site-packages/oras/provider.py", line 755, in push self._check_200_response(self.upload_manifest(manifest, container)) File "/Users/linsho/repos/oras-py/tmp/venv/lib/python3.10/site-packages/oras/provider.py", line 593, in _check_200_response raise ValueError(f"Issue with {response.request.url}: {response.reason}") ValueError: Issue with https://asia-northeast1-docker.pkg.dev/v2/example-repository/tmp/oras-test/manifests/v2: Not Found
attrs==23.1.0 certifi==2023.7.22 charset-normalizer==3.3.1 idna==3.4 jsonschema==4.19.1 jsonschema-specifications==2023.7.1 oras==0.1.25 referencing==0.30.2 requests==2.31.0 rpds-py==0.10.6 urllib3==2.0.7
That would be a good solution. Would you care to open a PR to fix this?
If manifest_config is not specified when pushing by oras-py, the implementation currently treats manifest_config as a completely empty string. https://github.com/oras-project/oras-py/blob/02c5bdacb54b5d7d6c152fcdbc0e11cf69b4900f/oras/oci.py#L130-L136
I was using google artifact registry and confirmed that push fails if manifest_config is an empty string.
The current workaround (or maybe this is the right way) is to create a file with only "{}" and read that file to successfully execute the push.
If manifest_config was not specified, why not change it so that the contents of manifest_config are treated as "{}"?
code
log
environment