Skip to content

Commit

Permalink
fix(podman_save): always changed when force (#834)
Browse files Browse the repository at this point in the history
fixes #826

Signed-off-by: Benjamin Menant <[email protected]>
  • Loading branch information
bmenant authored Sep 2, 2024
1 parent 552af3e commit ac3a7a5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugins/modules/podman_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ def save(module, executable):
for img in module.params['image']:
command.append(img)
if module.params['force']:
changed = True
dest = module.params['dest']
if os.path.exists(dest):
changed = True
if module.check_mode:
return changed, '', ''
try:
Expand Down
21 changes: 20 additions & 1 deletion tests/integration/targets/podman_save/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
executable: "{{ test_executable | default('podman') }}"
image: registry.k8s.io/pause
dest: /tmp/image.tar
force: false
register: saved_docker

- name: Check file
stat:
Expand All @@ -23,12 +25,13 @@
that:
- img.stat.exists

- name: Save image
- name: Save Force image
containers.podman.podman_save:
executable: "{{ test_executable | default('podman') }}"
image: registry.k8s.io/pause
dest: /tmp/image.tar
force: true
register: saved_forced

- name: Check file
stat:
Expand All @@ -46,6 +49,7 @@
image: registry.k8s.io/pause
dest: /tmp/imagedir
format: oci-dir
register: saved_oci_dir

- name: Check file
stat:
Expand All @@ -65,6 +69,7 @@
force: true
format: docker-dir
compress: true
register: saved_docker_dir

- name: Save image
containers.podman.podman_save:
Expand All @@ -73,6 +78,7 @@
dest: /tmp/imagedir
force: true
format: oci-dir
register: saved_oci_dir2

- name: Check file
stat:
Expand All @@ -90,6 +96,7 @@
image: registry.k8s.io/pause
dest: /tmp/image2.tar
multi_image_archive: true
register: saved_multi

- name: Check file
stat:
Expand All @@ -109,6 +116,7 @@
- registry.k8s.io/coredns/coredns:v1.9.3
dest: /tmp/image-multi.tar
multi_image_archive: true
register: saved_multi2

- name: Check mult image file
stat:
Expand All @@ -119,3 +127,14 @@
assert:
that:
- img.stat.exists

- name: Check results changed
assert:
that:
- saved_docker is changed
- saved_forced is changed
- saved_oci_dir is changed
- saved_docker_dir is changed
- saved_oci_dir2 is changed
- saved_multi is changed
- saved_multi2 is changed

0 comments on commit ac3a7a5

Please sign in to comment.