Skip to content

Commit

Permalink
Fix return type issues from PR feedback
Browse files Browse the repository at this point in the history
Signed-off-by: gw <[email protected]>
  • Loading branch information
gw committed Sep 23, 2024
1 parent a651c42 commit ec02a05
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions plugins/modules/podman_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,10 @@ def _get_id_from_output(self, lines, startswith=None, contains=None, split_on='
def _find_containerfile_from_context(self):
"""
Find a Containerfile/Dockerfile path inside a podman build context.
Return an empty string if none exist.
Return 'None' if none exist.
"""

containerfile_path = ""
containerfile_path = None
for filename in [os.path.join(self.path, fname) for fname in ["Containerfile", "Dockerfile"]]:
if os.path.exists(filename):
containerfile_path = filename
Expand All @@ -512,13 +512,16 @@ def _get_containerfile_contents(self):
See if either `file` or `container_file` in build args are populated,
fetch their contents if so. If not, return the contents of the Containerfile
or Dockerfile from inside the build context.
or Dockerfile from inside the build context, if present.
If we don't find a Containerfile/Dockerfile in any of the above
locations, return 'None'.
"""

build_file_arg = self.build.get('file') if self.build else None
containerfile_contents = self.build.get('container_file') if self.build else None

container_filename = ""
container_filename = None
if build_file_arg:
container_filename = build_file_arg
elif self.path and not build_file_arg:
Expand Down Expand Up @@ -550,7 +553,7 @@ def _get_args_containerfile_hash(self):

args_containerfile_hash = ""

context_has_containerfile = self.path and self._find_containerfile_from_context() != ""
context_has_containerfile = self.path and self._find_containerfile_from_context()

should_hash_args_containerfile = (
context_has_containerfile or
Expand Down Expand Up @@ -783,7 +786,7 @@ def build_image(self, containerfile_hash):
f.write(container_file_txt)
args.extend(['--file', container_file_path])

if containerfile_hash != "":
if containerfile_hash:
args.extend(['--label', f"containerfile.hash={containerfile_hash}"])

volume = self.build.get('volume')
Expand Down

0 comments on commit ec02a05

Please sign in to comment.