mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-15 19:42:06 +00:00
Improve image layer event parsing for Compose 5+.
This commit is contained in:
parent
0e017c93a8
commit
00094afaa6
@ -494,7 +494,17 @@ def parse_json_events(
|
||||
# {"dry-run":true,"id":"ansible-docker-test-dc713f1f-container ==> ==>","text":"naming to ansible-docker-test-dc713f1f-image"}
|
||||
# (The longer form happens since Docker Compose 2.39.0)
|
||||
continue
|
||||
if isinstance(resource_id, str) and " " in resource_id:
|
||||
if (
|
||||
status in ("Working", "Done")
|
||||
and isinstance(line_data.get("parent_id"), str)
|
||||
and line_data["parent_id"].startswith("Image ")
|
||||
):
|
||||
# Compose 5.0.0+:
|
||||
# {"id":"63a26ae4e8a8","parent_id":"Image ghcr.io/ansible-collections/simple-1:tag","status":"Working"}
|
||||
# {"id":"63a26ae4e8a8","parent_id":"Image ghcr.io/ansible-collections/simple-1:tag","status":"Done","percent":100}
|
||||
resource_type = ResourceType.IMAGE_LAYER
|
||||
resource_id = line_data["parent_id"][len("Image ") :]
|
||||
elif isinstance(resource_id, str) and " " in resource_id:
|
||||
resource_type_str, resource_id = resource_id.split(" ", 1)
|
||||
try:
|
||||
resource_type = ResourceType.from_docker_compose_event(
|
||||
|
||||
@ -494,64 +494,55 @@ JSON_TEST_CASES: list[tuple[str, str, str, list[Event], list[str]]] = [
|
||||
"Working",
|
||||
),
|
||||
Event(
|
||||
"unknown",
|
||||
"63a26ae4e8a8",
|
||||
"image-layer",
|
||||
"ghcr.io/ansible-collections/simple-1:tag",
|
||||
"Working",
|
||||
None,
|
||||
),
|
||||
Event(
|
||||
"unknown",
|
||||
"63a26ae4e8a8",
|
||||
"image-layer",
|
||||
"ghcr.io/ansible-collections/simple-1:tag",
|
||||
"Working",
|
||||
"[> ] 6.89kB/599.9kB",
|
||||
),
|
||||
Event(
|
||||
"unknown",
|
||||
"63a26ae4e8a8",
|
||||
"image-layer",
|
||||
"ghcr.io/ansible-collections/simple-1:tag",
|
||||
"Working",
|
||||
"[==================================================>] 599.9kB/599.9kB",
|
||||
),
|
||||
Event(
|
||||
"unknown",
|
||||
"63a26ae4e8a8",
|
||||
"image-layer",
|
||||
"ghcr.io/ansible-collections/simple-1:tag",
|
||||
"Working",
|
||||
None,
|
||||
),
|
||||
Event(
|
||||
"unknown",
|
||||
"63a26ae4e8a8",
|
||||
"Done",
|
||||
None,
|
||||
"image-layer", "ghcr.io/ansible-collections/simple-1:tag", "Done", None
|
||||
),
|
||||
Event(
|
||||
"unknown",
|
||||
"63a26ae4e8a8",
|
||||
"image-layer",
|
||||
"ghcr.io/ansible-collections/simple-1:tag",
|
||||
"Working",
|
||||
"[==> ] 32.77kB/599.9kB",
|
||||
),
|
||||
Event(
|
||||
"unknown",
|
||||
"63a26ae4e8a8",
|
||||
"Working",
|
||||
"[==================================================>] 599.9kB/599.9kB",
|
||||
),
|
||||
Event(
|
||||
"unknown",
|
||||
"63a26ae4e8a8",
|
||||
"Working",
|
||||
"[==================================================>] 599.9kB/599.9kB",
|
||||
),
|
||||
Event(
|
||||
"unknown",
|
||||
"63a26ae4e8a8",
|
||||
"Done",
|
||||
None,
|
||||
),
|
||||
Event(
|
||||
"image",
|
||||
"image-layer",
|
||||
"ghcr.io/ansible-collections/simple-1:tag",
|
||||
"Pulled",
|
||||
"Done",
|
||||
"Working",
|
||||
"[==================================================>] 599.9kB/599.9kB",
|
||||
),
|
||||
Event(
|
||||
"image-layer",
|
||||
"ghcr.io/ansible-collections/simple-1:tag",
|
||||
"Working",
|
||||
"[==================================================>] 599.9kB/599.9kB",
|
||||
),
|
||||
Event(
|
||||
"image-layer", "ghcr.io/ansible-collections/simple-1:tag", "Done", None
|
||||
),
|
||||
Event(
|
||||
"image", "ghcr.io/ansible-collections/simple-1:tag", "Pulled", "Done"
|
||||
),
|
||||
],
|
||||
[],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user