Convert str to json format before evaluating length in find_image()
and inspect_image()
.
#574
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
During working on #563, I found some strange behaviors of
podman_image.find_image()
andpodman_image.inspect_image()
.I guess this implementation is not as expected.
Details
These functions will execute
podman
commands such aspodman image ls <IMG_NAME> --format json
andpodman image inspect <IMG_NAME> --format json
.The following snippet is from
find_image()
, and it looksimages
is expected to receive a list fromrc, images, err = self._run(args, ignore_errors=True)
. Then its length will be evaluated.However, I believe that currently
images
isstr
type and it is[]\n
if the target image doesn't exist on a server. Solen(image)
will be not zero, but 3 or more.ansible-podman-collections/plugins/modules/podman_image.py
Lines 525 to 528 in d5f7655
I think that the expectation here is
len(image)
will be zero if the target image is absent.Therefore, this PR fixes that and converts str to json format before evaluating its length in
find_image()
andinspect_image()
.