mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-02-04 07:11:49 +00:00
Improve idempotency for volumes with slashes
In case of trailing slash or double slashes, the Podman strips it automatically. Prepare input data accordingly, so we can compare with Podman inspected one.
This commit is contained in:
parent
6b2bcef9b2
commit
0767d49a59
2 changed files with 10 additions and 4 deletions
|
|
@ -1744,6 +1744,10 @@ class PodmanContainerDiff:
|
|||
return self._diff_update_and_compare('uts', before, after)
|
||||
|
||||
def diffparam_volume(self):
|
||||
def clean_volume(x):
|
||||
'''Remove trailing and double slashes from volumes.'''
|
||||
return x.replace("//", "/").rstrip("/")
|
||||
|
||||
before = self.info['mounts']
|
||||
before_local_vols = []
|
||||
if before:
|
||||
|
|
@ -1757,7 +1761,9 @@ class PodmanContainerDiff:
|
|||
before = [":".join(v) for v in volumes]
|
||||
before_local_vols = [":".join(v) for v in local_vols]
|
||||
if self.params['volume'] is not None:
|
||||
after = [":".join(v.split(":")[:2]) for v in self.params['volume']]
|
||||
after = [":".join(
|
||||
[clean_volume(i) for i in v.split(":")[:2]]
|
||||
) for v in self.params['volume']]
|
||||
else:
|
||||
after = []
|
||||
if before_local_vols:
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@
|
|||
name: idempotency
|
||||
state: present
|
||||
volumes:
|
||||
- /opt:/somedir
|
||||
- /opt/://somedir
|
||||
command: 1h
|
||||
register: test5
|
||||
|
||||
|
|
@ -142,8 +142,8 @@
|
|||
state: present
|
||||
command: 1h
|
||||
volumes:
|
||||
- "/opt:/anotherdir"
|
||||
- "local_volume1:/data"
|
||||
- "/opt//:/anotherdir"
|
||||
- "local_volume1:/data/"
|
||||
register: test11
|
||||
|
||||
- name: check test11
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue