From 2a04d8fa7e9efa5e1ef5a1ea89d1d44e7992ae20 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Fri, 25 Jul 2025 22:15:53 +0200 Subject: [PATCH] Adjust to Compose 2.39.0+. (#1101) (#1102) (cherry picked from commit ac301beebd16db03319c9be2c662e7c541b79317) Co-authored-by: Felix Fontein --- changelogs/fragments/1101-compose.yml | 2 ++ plugins/module_utils/compose_v2.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/1101-compose.yml diff --git a/changelogs/fragments/1101-compose.yml b/changelogs/fragments/1101-compose.yml new file mode 100644 index 00000000..55493c13 --- /dev/null +++ b/changelogs/fragments/1101-compose.yml @@ -0,0 +1,2 @@ +bugfixes: + - "docker_compose_v2 - adjust to new dry-run build events in Docker Compose 2.39.0+ (https://github.com/ansible-collections/community.docker/pull/1101)." diff --git a/plugins/module_utils/compose_v2.py b/plugins/module_utils/compose_v2.py index 5fb0d180..304e45c6 100644 --- a/plugins/module_utils/compose_v2.py +++ b/plugins/module_utils/compose_v2.py @@ -432,13 +432,17 @@ def parse_json_events(stderr, warn_function=None): # {"dry-run":true,"id":" ","text":"build service app"} resource_id = "S" + text[len("build s"):] text = "Building" - if resource_id == "==>" and text and text.startswith("==> writing image "): + if isinstance(resource_id, str) and resource_id.endswith("==>") and text and text.startswith("==> writing image "): # Example: # {"dry-run":true,"id":"==>","text":"==> writing image dryRun-7d1043473d55bfa90e8530d35801d4e381bc69f0"} + # {"dry-run":true,"id":"ansible-docker-test-dc713f1f-container ==>","text":"==> writing image dryRun-5d9204268db1a73d57bbd24a25afbeacebe2bc02"} + # (The longer form happens since Docker Compose 2.39.0) continue - if resource_id == "==> ==>" and text and text.startswith("naming to "): + if isinstance(resource_id, str) and resource_id.endswith("==> ==>") and text and text.startswith("naming to "): # Example: # {"dry-run":true,"id":"==> ==>","text":"naming to display-app"} + # {"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: resource_type_str, resource_id = resource_id.split(' ', 1)