Check kubernetes resources using generic condition with jsonpath filter

Change-Id: I1922a835e98db723829c0c9f8438fb5617496707
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
diff --git a/osm_lcm/k8s.py b/osm_lcm/k8s.py
index e860a81..5d3cca4 100644
--- a/osm_lcm/k8s.py
+++ b/osm_lcm/k8s.py
@@ -224,7 +224,7 @@
                         item=checking["item"],
                         name=checking["name"],
                         namespace=checking["namespace"],
-                        flag=checking.get("flag"),
+                        condition=checking.get("condition"),
                         deleted=checking.get("deleted", False),
                         timeout=checking["timeout"],
                         kubectl=kubectl,
@@ -437,7 +437,10 @@
                     "item": "kustomization",
                     "name": cluster_kustomization_name,
                     "namespace": "managed-resources",
-                    "flag": "Ready",
+                    "condition": {
+                        "jsonpath_filter": "status.conditions[?(@.type=='Ready')].status",
+                        "value": "True",
+                    },
                     "timeout": 1500,
                     "enable": True,
                     "resourceState": "IN_PROGRESS.KUSTOMIZATION_READY",
@@ -446,7 +449,10 @@
                     "item": f"cluster_{cloud_type}",
                     "name": cluster_name,
                     "namespace": "",
-                    "flag": "Synced",
+                    "condition": {
+                        "jsonpath_filter": "status.conditions[?(@.type=='Synced')].status",
+                        "value": "True",
+                    },
                     "timeout": self._checkloop_resource_timeout,
                     "enable": True,
                     "resourceState": "IN_PROGRESS.RESOURCE_SYNCED.CLUSTER",
@@ -455,7 +461,10 @@
                     "item": f"cluster_{cloud_type}",
                     "name": cluster_name,
                     "namespace": "",
-                    "flag": "Ready",
+                    "condition": {
+                        "jsonpath_filter": "status.conditions[?(@.type=='Ready')].status",
+                        "value": "True",
+                    },
                     "timeout": self._checkloop_resource_timeout,
                     "enable": True,
                     "resourceState": "IN_PROGRESS.RESOURCE_READY.CLUSTER",
@@ -464,7 +473,10 @@
                     "item": "kustomization",
                     "name": f"{cluster_kustomization_name}-bstrp-fluxctrl",
                     "namespace": "managed-resources",
-                    "flag": "Ready",
+                    "condition": {
+                        "jsonpath_filter": "status.conditions[?(@.type=='Ready')].status",
+                        "value": "True",
+                    },
                     "timeout": self._checkloop_resource_timeout,
                     "enable": bootstrap,
                     "resourceState": "IN_PROGRESS.BOOTSTRAP_OK",
@@ -477,7 +489,10 @@
                 "item": f"nodepool_{cloud_type}",
                 "name": nodepool_name,
                 "namespace": "",
-                "flag": "Ready",
+                "condition": {
+                    "jsonpath_filter": "status.conditions[?(@.type=='Ready')].status",
+                    "value": "True",
+                },
                 "timeout": self._checkloop_resource_timeout,
                 "enable": True,
                 "resourceState": "IN_PROGRESS.RESOURCE_READY.NODEPOOL",
@@ -961,7 +976,10 @@
                 "item": "kustomization",
                 "name": f"{cluster_kustomization_name}-bstrp-fluxctrl",
                 "namespace": "managed-resources",
-                "flag": "Ready",
+                "condition": {
+                    "jsonpath_filter": "status.conditions[?(@.type=='Ready')].status",
+                    "value": "True",
+                },
                 "timeout": self._checkloop_kustomization_timeout,
                 "enable": bootstrap,
                 "resourceState": "IN_PROGRESS.BOOTSTRAP_OK",
@@ -1138,7 +1156,7 @@
 
         db_cluster["operatingState"] = "IDLE"
         # self.logger.info("db_cluster: {}".format(db_cluster))
-        # TODO: verify enxtcondition
+        # TODO: verify condition
         # For the moment, if the workflow completed successfully, then we update the db accordingly.
         if workflow_status:
             if "k8s_version" in op_params:
@@ -1168,7 +1186,10 @@
         #         "item": "kustomization",
         #         "name": cluster_kustomization_name,
         #         "namespace": "managed-resources",
-        #         "flag": "Ready",
+        #         "condition": {
+        #             "jsonpath_filter": "status.conditions[?(@.type=='Ready')].status",
+        #             "value": "True",
+        #         },
         #         "timeout": self._checkloop_kustomization_timeout,
         #         "enable": True,
         #         "resourceState": "IN_PROGRESS.KUSTOMIZATION_READY",
@@ -2004,7 +2025,10 @@
                         "item": "kustomization",
                         "name": kustomization_name,
                         "namespace": target_ns,
-                        "flag": "Ready",
+                        "condition": {
+                            "jsonpath_filter": "status.conditions[?(@.type=='Ready')].status",
+                            "value": "True",
+                        },
                         "timeout": self._checkloop_kustomization_timeout,
                         "enable": True,
                         "resourceState": "IN_PROGRESS.KUSTOMIZATION_READY",