Skip to content

Commit

Permalink
Improve parsing. (#786)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein authored Feb 1, 2024
1 parent c97ac23 commit 7b55408
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/786-docker_v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "docker_compose_v2, docker_compose_v2_pull - fix parsing of pull messages for Docker Compose 2.20.0 (https://github.com/ansible-collections/community.docker/issues/785, https://github.com/ansible-collections/community.docker/pull/786)."
3 changes: 2 additions & 1 deletion plugins/module_utils/compose_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
))
DOCKER_PULL_PROGRESS_WORKING = frozenset((
'Pulling fs layer',
'Waiting',
'Downloading',
'Verifying Checksum',
'Extracting',
Expand Down Expand Up @@ -130,7 +131,7 @@ def from_docker_compose_event(cls, resource_type):
r'\s+'
r'(?P<status>%s)'
r'\s*'
r'(?:|\s\[[^]]+\]\s+\S+\s*)'
r'(?:|\s\[[^]]+\]\s+\S+\s*|\s+[0-9.kKmMgGbB]+/[0-9.kKmMgGbB]+\s*)'
r'$'
% '|'.join(re.escape(status) for status in sorted(DOCKER_PULL_PROGRESS_DONE | DOCKER_PULL_PROGRESS_WORKING))
)
Expand Down
100 changes: 100 additions & 0 deletions tests/unit/plugins/module_utils/test_compose_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,106 @@
],
[],
),
(
# https://github.com/ansible-collections/community.docker/issues/785
'2.20.0-manual-pull',
'2.20.0',
False,
'4f4fb700ef54 Waiting\n'
'238022553356 Downloading 541B/541B\n'
'972e292d3a60 Downloading 106kB/10.43MB\n'
'f2543dc9f0a9 Downloading 25.36kB/2.425MB\n'
'972e292d3a60 Downloading 5.925MB/10.43MB\n'
'f2543dc9f0a9 Downloading 2.219MB/2.425MB\n'
'f2543dc9f0a9 Extracting 32.77kB/2.425MB\n'
'4f4fb700ef54 Downloading 32B/32B\n'
'f2543dc9f0a9 Extracting 2.425MB/2.425MB\n'
'972e292d3a60 Extracting 131.1kB/10.43MB\n'
'972e292d3a60 Extracting 10.43MB/10.43MB\n'
'238022553356 Extracting 541B/541B\n'
'4f4fb700ef54 Extracting 32B/32B\n',
[
Event(
'image-layer',
'4f4fb700ef54',
'Waiting',
None,
),
Event(
'image-layer',
'238022553356',
'Downloading',
None,
),
Event(
'image-layer',
'972e292d3a60',
'Downloading',
None,
),
Event(
'image-layer',
'f2543dc9f0a9',
'Downloading',
None,
),
Event(
'image-layer',
'972e292d3a60',
'Downloading',
None,
),
Event(
'image-layer',
'f2543dc9f0a9',
'Downloading',
None,
),
Event(
'image-layer',
'f2543dc9f0a9',
'Extracting',
None,
),
Event(
'image-layer',
'4f4fb700ef54',
'Downloading',
None,
),
Event(
'image-layer',
'f2543dc9f0a9',
'Extracting',
None,
),
Event(
'image-layer',
'972e292d3a60',
'Extracting',
None,
),
Event(
'image-layer',
'972e292d3a60',
'Extracting',
None,
),
Event(
'image-layer',
'238022553356',
'Extracting',
None,
),
Event(
'image-layer',
'4f4fb700ef54',
'Extracting',
None,
),
],
[],
),
]

_ALL_TEST_CASES = EVENT_TEST_CASES + EXTRA_TEST_CASES
Expand Down

0 comments on commit 7b55408

Please sign in to comment.