From ed0ff05f09f276c753e5aa5439a3a1252b6a07e4 Mon Sep 17 00:00:00 2001 From: Pedro Escaleira Date: Sun, 3 Apr 2022 13:51:46 +0100 Subject: [PATCH] Bug 1965 fixed Parsed the manifest returned by the `helm status` command (in the `_status_kdu` method) from a raw string to a list of dictionaries (each entry in the list corresponds to each manifest's document). Change-Id: I791c8fd59fee8ac67bcbd640a100bf63d572efcf Signed-off-by: Pedro Escaleira --- n2vc/k8s_helm3_conn.py | 11 +++++++++-- n2vc/k8s_helm_conn.py | 9 +++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/n2vc/k8s_helm3_conn.py b/n2vc/k8s_helm3_conn.py index 82a29a6..8bfd173 100644 --- a/n2vc/k8s_helm3_conn.py +++ b/n2vc/k8s_helm3_conn.py @@ -404,11 +404,18 @@ class K8sHelm3Connector(K8sHelmBaseConnector): # remove field 'notes' and manifest try: del data.get("info")["notes"] - del data["manifest"] except KeyError: pass - # unable to parse 'resources' as currently it is not included in helm3 + # parse the manifest to a list of dictionaries + if "manifest" in data: + manifest_str = data.get("manifest") + manifest_docs = yaml.load_all(manifest_str, Loader=yaml.SafeLoader) + + data["manifest"] = [] + for doc in manifest_docs: + data["manifest"].append(doc) + return data def _get_install_command( diff --git a/n2vc/k8s_helm_conn.py b/n2vc/k8s_helm_conn.py index b11ddd0..444f2da 100644 --- a/n2vc/k8s_helm_conn.py +++ b/n2vc/k8s_helm_conn.py @@ -500,6 +500,15 @@ class K8sHelmConnector(K8sHelmBaseConnector): except KeyError: pass + # parse the manifest to a list of dictionaries + if "manifest" in data: + manifest_str = data.get("manifest") + manifest_docs = yaml.load_all(manifest_str, Loader=yaml.SafeLoader) + + data["manifest"] = [] + for doc in manifest_docs: + data["manifest"].append(doc) + # parse field 'resources' try: resources = str(data.get("info").get("status").get("resources")) -- 2.17.1