mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-02-04 07:11:49 +00:00
Fix idempotency for empty values (#790)
Fix #788 Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
parent
f9aa8878fd
commit
24c842fdd6
2 changed files with 42 additions and 0 deletions
|
|
@ -404,11 +404,15 @@ def diff_generic(params, info_config, module_arg, cmd_arg, boolean_type=False):
|
||||||
after = ",".join(sorted([str(i).lower() for i in after]))
|
after = ",".join(sorted([str(i).lower() for i in after]))
|
||||||
if before:
|
if before:
|
||||||
before = ",".join(sorted([str(i).lower() for i in before]))
|
before = ",".join(sorted([str(i).lower() for i in before]))
|
||||||
|
else:
|
||||||
|
before = ''
|
||||||
elif isinstance(after, dict):
|
elif isinstance(after, dict):
|
||||||
after = ",".join(sorted(
|
after = ",".join(sorted(
|
||||||
[str(k).lower() + "=" + str(v).lower() for k, v in after.items() if v is not None]))
|
[str(k).lower() + "=" + str(v).lower() for k, v in after.items() if v is not None]))
|
||||||
if before:
|
if before:
|
||||||
before = ",".join(sorted([j.lower() for j in before]))
|
before = ",".join(sorted([j.lower() for j in before]))
|
||||||
|
else:
|
||||||
|
before = ''
|
||||||
elif isinstance(after, bool):
|
elif isinstance(after, bool):
|
||||||
after = str(after).capitalize()
|
after = str(after).capitalize()
|
||||||
if before is not None:
|
if before is not None:
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,44 @@
|
||||||
assert:
|
assert:
|
||||||
that: test1 is not changed
|
that: test1 is not changed
|
||||||
|
|
||||||
|
- name: Run container with empty vars for list and dict
|
||||||
|
containers.podman.podman_container:
|
||||||
|
executable: "{{ test_executable | default('podman') }}"
|
||||||
|
image: "{{ idem_image }}"
|
||||||
|
name: idempotency
|
||||||
|
state: present
|
||||||
|
env: {}
|
||||||
|
publish: []
|
||||||
|
command: 1h
|
||||||
|
register: test_to_empty
|
||||||
|
|
||||||
|
- name: Run container with empty vars for list and dict - again
|
||||||
|
containers.podman.podman_container:
|
||||||
|
executable: "{{ test_executable | default('podman') }}"
|
||||||
|
image: "{{ idem_image }}"
|
||||||
|
name: idempotency
|
||||||
|
state: present
|
||||||
|
env: {}
|
||||||
|
publish: []
|
||||||
|
command: 1h
|
||||||
|
register: test_empty
|
||||||
|
|
||||||
|
- name: Run container again w/o empty vars
|
||||||
|
containers.podman.podman_container:
|
||||||
|
executable: "{{ test_executable | default('podman') }}"
|
||||||
|
image: "{{ idem_image }}"
|
||||||
|
name: idempotency
|
||||||
|
state: present
|
||||||
|
command: 1h
|
||||||
|
register: test_from_empty
|
||||||
|
|
||||||
|
- name: Check info when running container again
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- test_to_empty is not changed
|
||||||
|
- test_empty is not changed
|
||||||
|
- test_from_empty is not changed
|
||||||
|
|
||||||
- name: Run container with environment vars
|
- name: Run container with environment vars
|
||||||
containers.podman.podman_container:
|
containers.podman.podman_container:
|
||||||
executable: "{{ test_executable | default('podman') }}"
|
executable: "{{ test_executable | default('podman') }}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue