Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: supply manifest list digest to pyxis #310

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions pyxis/create_container_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,11 @@ def pyxis_tags(args, date_now):
]


def repository_digest_values(args, docker_image_digest):
def repository_digest_values(args):
"""Return digest values for the repository entry in the image entity"""
result = {"manifest_schema2_digest": args.architecture_digest}
if args.media_type in MANIFEST_LIST_TYPES:
result["manifest_list_digest"] = docker_image_digest
result["manifest_list_digest"] = args.digest
return result


Expand All @@ -261,12 +261,10 @@ def create_container_image(args, parsed_data: Dict[str, Any]):

date_now = datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f+00:00")

if "digest" not in parsed_data:
raise Exception("Digest was not found in the passed oras manifest json")
if "name" not in parsed_data:
raise Exception("Name was not found in the passed oras manifest json")
docker_image_digest = parsed_data["digest"]
# digest isn't accepted in the parsed_data payload to pyxis

# digest isn't accepted in the parsed_data payload to pyxis; we ignore it
del parsed_data["digest"]

image_name = parsed_data["name"]
Expand Down Expand Up @@ -309,9 +307,7 @@ def create_container_image(args, parsed_data: Dict[str, Any]):
if uncompressed_top_layer_id:
container_image_payload["uncompressed_top_layer_id"] = uncompressed_top_layer_id

container_image_payload["repositories"][0].update(
repository_digest_values(args, docker_image_digest)
)
container_image_payload["repositories"][0].update(repository_digest_values(args))

# For images released to registry.redhat.io we need a second repository item
# with published=true and registry and repository converted.
Expand Down Expand Up @@ -347,7 +343,6 @@ def add_container_image_repository(args, parsed_data: Dict[str, Any], image: Dic
date_now = datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f+00:00")

image_name = parsed_data["name"]
docker_image_digest = parsed_data["digest"]

patch_url = urljoin(args.pyxis_url, f"v1/images/id/{identifier}")

Expand All @@ -360,7 +355,7 @@ def add_container_image_repository(args, parsed_data: Dict[str, Any], image: Dic
"tags": pyxis_tags(args, date_now),
}
)
image["repositories"][-1].update(repository_digest_values(args, docker_image_digest))
image["repositories"][-1].update(repository_digest_values(args))

rsp = pyxis.patch(patch_url, image).json()

Expand Down
2 changes: 2 additions & 0 deletions pyxis/test_create_container_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def test_create_container_image_latest(mock_datetime, mock_post):
args.certified = "false"
args.is_latest = "true"
args.rh_push = "false"
args.digest = "some_digest"
args.architecture_digest = "arch specific digest"
args.media_type = "application/vnd.oci.image.index.v1+json"

Expand Down Expand Up @@ -262,6 +263,7 @@ def test_create_container_image_rh_push_multiple_tags(mock_datetime, mock_post):
args.tags = "tagprefix tagprefix-timestamp"
args.certified = "false"
args.rh_push = "true"
args.digest = "some_digest"
args.architecture_digest = "arch specific digest"
args.media_type = "application/vnd.oci.image.index.v1+json"

Expand Down