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 digests of layers meta #352

Merged
merged 2 commits into from
Oct 2, 2024
Merged
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
2 changes: 1 addition & 1 deletion apps/docker_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def get_layer_digest(self, diff_id, idx):
["skopeo", "inspect", f"docker://{self._image_ref}"])
image_desc = json.loads(output)
for layer in image_desc["Layers"]:
self._layer_digests.append(layer[len(self._SUPPORTED_HASH_TYPE):])
self._layer_digests.append(layer)

if len(self._layer_digests) <= idx:
raise Exception("the number of image layer diffIDs and layer digests does not"
Expand Down
20 changes: 17 additions & 3 deletions apps/get_layers_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,23 @@ def print_layer_details(layer: DockerStore.Layer):

image = docker_store.images_by_ref.get(img_uri)
if not image:
status("Image metadata are not found in local store; "
f"`SKIP_ARCHS` must be set for the image: {img_uri}", prefix="==== ")
continue
# Docker daemon stores image refs in repositories.json without the docker
# hub prefixes regardless whether an image is specified in a short or full format
# during docker pull or in docker-compose.yml. There are two possible short formats:
# 1. <name>:<tag> --> docker.io/library/<name>:<tag>
# 2. <org>/<name>:<tag> --> docker.io/<org>/<name>:<tag>
# Let's check if the image hosted in docker/.io and specified in a long format
# matches one of the images stored in the local docker store and references in
# the short form.
for docker_hub_prefix in ["docker.io/library/", "docker.io/"]:
if img_uri.startswith(docker_hub_prefix):
image = docker_store.images_by_ref.get(img_uri[len(docker_hub_prefix):])
if image:
break
if not image:
status("Image metadata are not found in local store; "
f"`SKIP_ARCHS` must be set for the image: {img_uri}", prefix="==== ")
continue

status(f"Image: {img_uri}", prefix="==== ")
for layer in image.layers:
Expand Down