From ac41379119817274c63801390f0f3001393c795d Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 20 Jan 2024 14:12:55 +0100 Subject: [PATCH] Fix archive idempotency. (#765) --- changelogs/fragments/765-docker_image-archive.yml | 2 ++ plugins/module_utils/image_archive.py | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 changelogs/fragments/765-docker_image-archive.yml diff --git a/changelogs/fragments/765-docker_image-archive.yml b/changelogs/fragments/765-docker_image-archive.yml new file mode 100644 index 00000000..35b4cd2e --- /dev/null +++ b/changelogs/fragments/765-docker_image-archive.yml @@ -0,0 +1,2 @@ +bugfixes: + - "docker_image - fix archiving idempotency with Docker API 1.44 or later (https://github.com/ansible-collections/community.docker/pull/765)." diff --git a/plugins/module_utils/image_archive.py b/plugins/module_utils/image_archive.py index e174631e..11e615f2 100644 --- a/plugins/module_utils/image_archive.py +++ b/plugins/module_utils/image_archive.py @@ -126,6 +126,12 @@ def archived_image_manifest(archive_path): exc ) + for prefix in ( + 'blobs/sha256/', # Moby 25.0.0, Docker API 1.44 + ): + if image_id.startswith(prefix): + image_id = image_id[len(prefix):] + try: repo_tags = m0['RepoTags'] except KeyError as exc: