community.docker/tests/unit/plugins/module_utils
Paul Berruti 21288cda7e Fix _image_lookup to handle combined tag@digest format
The parse_repository_tag fix alone is not sufficient because Docker stores
RepoTags and RepoDigests separately. When looking up an image with combined
tag@digest (e.g., nginx:1.21@sha256:abc...), the _image_lookup function must
split the combined format and match BOTH RepoTags (for the tag) AND
RepoDigests (for the digest).

Docker stores:
- RepoTags: ["nginx:1.21"]
- RepoDigests: ["nginx@sha256:abc..."]

But NEVER stores the combined format. The previous code would construct:
- lookup = "nginx:1.21@sha256:abc..." (never matches RepoTags)
- lookup_digest = "nginx@1.21@sha256:abc..." (never matches RepoDigests)

This fix:
1. Adds filter_images_by_tag() helper function to _util.py to avoid code
   duplication between _common.py and _common_api.py
2. Detects combined tag@digest format in the tag parameter
3. Splits into tag_part and digest_part
4. Constructs proper lookups for both RepoTags and RepoDigests
5. Requires BOTH to match for successful image lookup

Without this fix, image_label_mismatch: ignore fails because the image
cannot be found, resulting in no image labels being included in expected
labels comparison.

Includes comprehensive unit tests in test__util.py covering all scenarios
including edge cases for multiple @ symbols and empty tag parts.
2025-11-22 20:10:21 -08:00
..
_api Fix parse_repository_tag to handle images with both tag and digest 2025-11-22 16:58:54 -08:00
compose_v2_test_cases.py Add typing information, 2/n (#1178) 2025-10-25 01:16:04 +02:00
test__compose_v2.py Add typing information, 2/n (#1178) 2025-10-25 01:16:04 +02:00
test__copy.py Add typing information, 2/n (#1178) 2025-10-25 01:16:04 +02:00
test__image_archive.py Python code modernization, 8/n (#1179) 2025-10-25 00:36:04 +00:00
test__logfmt.py Add typing information, 2/n (#1178) 2025-10-25 01:16:04 +02:00
test__scramble.py Add typing information, 2/n (#1178) 2025-10-25 01:16:04 +02:00
test__util.py Fix _image_lookup to handle combined tag@digest format 2025-11-22 20:10:21 -08:00