X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=n2vc%2Fk8s_helm3_conn.py;h=bb08f0792aaeddd542fa1e8e065d8efbeb2d7139;hp=82a29a6f19b63a6d7fb28a1791bea9134fd61003;hb=a8980cc3f6508f2659dc4ba4fcbeed65ba3c8e95;hpb=b41de17df6282334088ffbd887fbc01e496e1797;ds=sidebyside diff --git a/n2vc/k8s_helm3_conn.py b/n2vc/k8s_helm3_conn.py index 82a29a6..bb08f07 100644 --- a/n2vc/k8s_helm3_conn.py +++ b/n2vc/k8s_helm3_conn.py @@ -19,6 +19,7 @@ # For those usages not covered by the Apache License, Version 2.0 please # contact with: nfvlabs@tid.es ## +from typing import Union import os import yaml @@ -367,9 +368,9 @@ class K8sHelm3Connector(K8sHelmBaseConnector): cluster_id: str, kdu_instance: str, namespace: str = None, + yaml_format: bool = False, show_error_log: bool = False, - return_text: bool = False, - ): + ) -> Union[str, dict]: self.log.debug( "status of kdu_instance: {}, namespace: {} ".format(kdu_instance, namespace) @@ -393,7 +394,7 @@ class K8sHelm3Connector(K8sHelmBaseConnector): env=env, ) - if return_text: + if yaml_format: return str(output) if rc != 0: @@ -404,11 +405,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(