Adjust to Compose 2.39.0+. (#1101)

This commit is contained in:
Felix Fontein 2025-07-25 21:59:41 +02:00 committed by GitHub
parent 8365810b52
commit ac301beebd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -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)."

View File

@ -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)