1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-02-04 07:11:49 +00:00

Fix podman image permissions issue and runlable test (#853)

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
Sergey 2024-09-26 09:50:54 +03:00 committed by GitHub
parent 36c146a633
commit 4f8ab01fbb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 57 additions and 43 deletions

View file

@ -527,7 +527,7 @@ class PodmanImageManager(object):
elif self.path and not build_file_arg:
container_filename = self._find_containerfile_from_context()
if not containerfile_contents:
if not containerfile_contents and os.access(container_filename, os.R_OK):
with open(container_filename) as f:
containerfile_contents = f.read()
@ -538,6 +538,8 @@ class PodmanImageManager(object):
When given the contents of a Containerfile/Dockerfile,
return a sha256 hash of these contents.
"""
if not containerfile_contents:
return None
return hashlib.sha256(
containerfile_contents.encode(),
usedforsecurity=False
@ -551,7 +553,7 @@ class PodmanImageManager(object):
If we don't have this, return an empty string.
"""
args_containerfile_hash = ""
args_containerfile_hash = None
context_has_containerfile = self.path and self._find_containerfile_from_context()
@ -581,9 +583,7 @@ class PodmanImageManager(object):
else:
digest_before = None
both_hashes_exist_and_differ = (
args_containerfile_hash != "" and
existing_image_containerfile_hash != "" and
both_hashes_exist_and_differ = (args_containerfile_hash and existing_image_containerfile_hash and
args_containerfile_hash != existing_image_containerfile_hash
)

View file

@ -4,6 +4,8 @@
path: /tmp/usr_img
state: directory
- block:
- name: Copy Dockerfile to container build directory
copy:
src: "{{ item }}"
@ -46,3 +48,15 @@
- name: Make sure install label exited with 128
assert:
that: install_runlabel.stdout == 'Installed.'
always:
- name: Remove the directory
file:
path: /tmp/usr_img
state: absent
- name: Remove the image
containers.podman.podman_image:
executable: "{{ test_executable | default('podman') }}"
name: "{{ runlabel_image }}"
state: absent