Skip to content

Commit

Permalink
core: make push response the one pertaining to Manifest (not config (#…
Browse files Browse the repository at this point in the history
…146)

* core: make push response the one pertaining to Manifest (not config)
* implementation (step 2/2)

Reproducer test (step 1/2)

Signed-off-by: tarilabs <matteo.mortari@gmail.com>
  • Loading branch information
tarilabs authored Jun 25, 2024
1 parent fd8a83c commit b8c4885
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
5 changes: 4 additions & 1 deletion oras/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,10 @@ def push(

# Final upload of the manifest
manifest["config"] = conf
self._check_200_response(self.upload_manifest(manifest, container))
response = self.upload_manifest(
manifest, container
) # make the returned response from this method, the one pertaining to the uploaded Manifest
self._check_200_response(response)
print(f"Successfully pushed {container}")
return response

Expand Down
22 changes: 22 additions & 0 deletions oras/tests/test_oras.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,28 @@ def test_basic_push_pull(tmp_path, registry, credentials, target):
assert res.status_code == 201


@pytest.mark.with_auth(False)
def test_basic_push_pul_via_sha_ref(tmp_path, registry, credentials, target):
"""
Basic tests for oras pushing and then pulling with SHA reference
"""
client = oras.client.OrasClient(hostname=registry, insecure=True)
artifact = os.path.join(here, "artifact.txt")

assert os.path.exists(artifact)

res = client.push(files=[artifact], target=target)
assert res.status_code in [200, 201]

# Test pulling elsewhere
using_ref = f"{registry}/dinosaur/artifact@{res.headers['Docker-Content-Digest']}"
files = client.pull(target=using_ref, outdir=tmp_path)
assert len(files) == 1
assert os.path.basename(files[0]) == "artifact.txt"
assert str(tmp_path) in files[0]
assert os.path.exists(files[0])


@pytest.mark.with_auth(False)
def test_get_delete_tags(tmp_path, registry, credentials, target):
"""
Expand Down

0 comments on commit b8c4885

Please sign in to comment.