mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-02-04 07:11:49 +00:00
podman pod info: handle return being list in Podman 5
Fixes #712 Podman 5 changed the output of `podman pod info` (when run on a single pod) from being a dict to being a list of dicts: https://github.com/containers/podman/pull/21514 this should handle both ways. Unfortunately not sure how to add a test for this as I can't see a unit test that mocks the output of the command, only the integration test that gets real live output, and I'm not sure how to get that test run with Podman 5. Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
parent
efbfba7c3c
commit
bba2d99318
1 changed files with 10 additions and 1 deletions
|
|
@ -658,7 +658,16 @@ class PodmanPod:
|
|||
# pylint: disable=unused-variable
|
||||
rc, out, err = self.module.run_command(
|
||||
[self.module_params['executable'], b'pod', b'inspect', self.name])
|
||||
return json.loads(out) if rc == 0 else {}
|
||||
if rc == 0:
|
||||
info = json.loads(out)
|
||||
# from podman 5 onwards, this is a list of dicts,
|
||||
# before it was just a single dict when querying
|
||||
# a single pod
|
||||
if isinstance(info, list):
|
||||
return info[0]
|
||||
else:
|
||||
return info
|
||||
return {}
|
||||
|
||||
def get_ps(self):
|
||||
"""Inspect pod process and gather info about it."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue