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 list tags failure in podman_search #875

Merged
merged 1 commit into from
Nov 5, 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
10 changes: 6 additions & 4 deletions plugins/modules/podman_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ def search_images(module, executable, term, limit, list_tags):
command.extend(['--list-tags'])

rc, out, err = module.run_command(command)

if rc != 0 and list_tags and out == "" and "fetching tags list" in err:
return out, err
if rc != 0:
module.fail_json(msg="Unable to gather info for '{0}': {1}".format(term, err))
return out
return out, err


def main():
Expand All @@ -110,7 +111,7 @@ def main():
list_tags = module.params.get('list_tags')
executable = module.get_bin_path(executable, required=True)

result_str = search_images(module, executable, term, limit, list_tags)
result_str, errors = search_images(module, executable, term, limit, list_tags)
if result_str == "":
results = []
else:
Expand All @@ -121,7 +122,8 @@ def main():

results = dict(
changed=False,
images=results
images=results,
stderr=errors,
)

module.exit_json(**results)
Expand Down
12 changes: 12 additions & 0 deletions tests/integration/targets/podman_search/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
that:
- info_0.images | length == 0

- name: Search for an invalid image with tags
containers.podman.podman_search:
term: registry.fedoraproject.org/invalidtermnope
executable: "{{ test_executable | default('podman') }}"
list_tags: true
register: info_0_1

- name: Check results for no matching images
assert:
that:
- info_0_1.images | length == 0

- name: Search for matching images
containers.podman.podman_search:
term: etcd
Expand Down