mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 11:55:04 +00:00
docker_prune: correctly return 'changed' result (#593)
* Correctly return 'changed' status. * Extend tests. * Fix typo.
This commit is contained in:
@@ -40,7 +40,8 @@
|
||||
command: docker volume list
|
||||
|
||||
# Prune objects
|
||||
- docker_prune:
|
||||
- name: Prune everything
|
||||
docker_prune:
|
||||
containers: true
|
||||
images: true
|
||||
networks: true
|
||||
@@ -55,6 +56,7 @@
|
||||
- name: General checks
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
# containers
|
||||
- container.container.Id in result.containers
|
||||
- "'containers_space_reclaimed' in result"
|
||||
@@ -81,6 +83,37 @@
|
||||
- volume.volume.Name not in result.volumes
|
||||
when: docker_api_version is version('1.42', '>=')
|
||||
|
||||
# Prune objects again
|
||||
- name: Prune everything again (should have no change)
|
||||
docker_prune:
|
||||
containers: true
|
||||
images: true
|
||||
networks: true
|
||||
volumes: true
|
||||
builder_cache: true
|
||||
register: result
|
||||
|
||||
# Analyze result
|
||||
- name: Show results
|
||||
debug:
|
||||
var: result
|
||||
- name: General checks
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
# containers
|
||||
- result.containers == []
|
||||
- result.containers_space_reclaimed == 0
|
||||
# images
|
||||
- result.images == []
|
||||
- result.images_space_reclaimed == 0
|
||||
# networks
|
||||
- result.networks == []
|
||||
# volumes
|
||||
- result.volumes == []
|
||||
# builder_cache
|
||||
- result.builder_cache_space_reclaimed == 0
|
||||
|
||||
# Test with filters
|
||||
- name: Prune with filters
|
||||
docker_prune:
|
||||
@@ -110,6 +143,7 @@
|
||||
- name: Check results
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- volume.volume.Name in result.volumes
|
||||
- "'volumes_space_reclaimed' in result"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user