mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-02-04 07:11:49 +00:00
Fix pulling short image name
Also return image data when pulling it. Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
parent
7a307453a5
commit
1699be8e3f
2 changed files with 29 additions and 8 deletions
|
|
@ -512,6 +512,8 @@ class PodmanImageManager(object):
|
|||
if not self.module.check_mode:
|
||||
self.results['image'], output = self.push_image()
|
||||
self.results['stdout'] += "\n" + output
|
||||
if image and not self.results.get('image'):
|
||||
self.results['image'] = image
|
||||
|
||||
def absent(self):
|
||||
image = self.find_image()
|
||||
|
|
@ -537,11 +539,17 @@ class PodmanImageManager(object):
|
|||
args = ['image', 'ls', image_name, '--format', 'json']
|
||||
rc, images, err = self._run(args, ignore_errors=True)
|
||||
images = json.loads(images)
|
||||
if len(images) == 0:
|
||||
# Let's find out if image exists
|
||||
rc, out, err = self._run(['image', 'exists', image_name], ignore_errors=True)
|
||||
if rc == 0:
|
||||
inspect_json = self.inspect_image(image_name)
|
||||
else:
|
||||
return None
|
||||
if len(images) > 0:
|
||||
inspect_json = self.inspect_image(image_name)
|
||||
if self._is_target_arch(inspect_json, self.arch) or not self.arch:
|
||||
return images
|
||||
|
||||
if self._is_target_arch(inspect_json, self.arch) or not self.arch:
|
||||
return images or inspect_json
|
||||
return None
|
||||
|
||||
def _is_target_arch(self, inspect_json=None, arch=None):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,18 @@
|
|||
- name: Test podman_image
|
||||
block:
|
||||
- name: List all images on host before test
|
||||
containers.podman.podman_image_info:
|
||||
|
||||
- name: Remove images for test
|
||||
containers.podman.podman_image:
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- quay.io/coreos/alpine-sh
|
||||
- docker.io/alpine
|
||||
- docker.io/library/ubuntu
|
||||
- docker.io/library/alpine
|
||||
|
||||
- name: Pull image
|
||||
containers.podman.podman_image:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
|
|
@ -47,7 +60,7 @@
|
|||
- pull1.podman_actions is defined
|
||||
- pull2 is not changed
|
||||
- pull3 is changed
|
||||
- pull4 is changed
|
||||
- pull4 is not changed
|
||||
- pull5 is not changed
|
||||
- pull6 is changed
|
||||
- "'alpine-sh' in images.stdout"
|
||||
|
|
@ -83,14 +96,14 @@
|
|||
state: absent
|
||||
register: rmi3
|
||||
|
||||
- name: Try to remove docker.io image using short url
|
||||
- name: Remove docker.io image using short url
|
||||
containers.podman.podman_image:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
name: docker.io/alpine
|
||||
state: absent
|
||||
register: rmi4
|
||||
|
||||
- name: Remove docker.io image using normalised url
|
||||
- name: Try to remove docker.io image using normalised url
|
||||
containers.podman.podman_image:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
name: docker.io/library/alpine
|
||||
|
|
@ -121,8 +134,8 @@
|
|||
- rmi1 is changed
|
||||
- rmi2 is not changed
|
||||
- rmi3 is changed
|
||||
- rmi4 is not changed
|
||||
- rmi5 is changed
|
||||
- rmi4 is changed
|
||||
- rmi5 is not changed
|
||||
- rmi6 is changed
|
||||
- "'alpine-sh' not in images.stdout"
|
||||
- "'library/ubuntu' not in images.stdout"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue