From cd408233d6ba7369eaf26e7b621b6e88711a907e Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Mar 02 2024 02:28:00 +0000 Subject: commit patch --- diff --git a/podman-pod-info-5.patch b/podman-pod-info-5.patch new file mode 100644 index 0000000..23310dd --- /dev/null +++ b/podman-pod-info-5.patch @@ -0,0 +1,44 @@ +From bba2d99318ca6dbd567dadaf4be8db8a05e74b9b Mon Sep 17 00:00:00 2001 +From: Adam Williamson +Date: Thu, 15 Feb 2024 17:25:22 -0800 +Subject: [PATCH] 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 +--- + plugins/module_utils/podman/podman_pod_lib.py | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/plugins/module_utils/podman/podman_pod_lib.py b/plugins/module_utils/podman/podman_pod_lib.py +index 4106136e..0ed30dbd 100644 +--- a/plugins/module_utils/podman/podman_pod_lib.py ++++ b/plugins/module_utils/podman/podman_pod_lib.py +@@ -658,7 +658,16 @@ def get_info(self): + # 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."""