Bug 1965 fixed 26/11826/3
authorPedro Escaleira <escaleira@av.it.pt>
Sun, 3 Apr 2022 12:51:46 +0000 (13:51 +0100)
committergarciadav <david.garcia@canonical.com>
Fri, 22 Apr 2022 10:36:42 +0000 (12:36 +0200)
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 <escaleira@av.it.pt>
n2vc/k8s_helm3_conn.py
n2vc/k8s_helm_conn.py

index 82a29a6..8bfd173 100644 (file)
@@ -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(
index b11ddd0..444f2da 100644 (file)
@@ -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"))