Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(podman_save): always changed when force #834

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading