From c6aa2be27352d77093cad1ac616ee8adafdeb79d Mon Sep 17 00:00:00 2001
From: Maarten de Waard <maarten@greenhost.nl>
Date: Mon, 3 Oct 2022 16:00:42 +0200
Subject: [PATCH] adding and removing functions as result of merge conflict

---
 areas/apps/apps.py    |  8 --------
 areas/apps/models.py  | 20 --------------------
 helpers/kubernetes.py | 23 +++++++++++++++++++++++
 3 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/areas/apps/apps.py b/areas/apps/apps.py
index de85bbc1..33739690 100644
--- a/areas/apps/apps.py
+++ b/areas/apps/apps.py
@@ -21,14 +21,6 @@ CONFIG_DATA = [
     }
 ]
 
-APPS_DATA = [
-    {"id": 1, "name": "Nextcloud", "enabled": True, "status": "ON for everyone"},
-    {"id": 2, "name": "Rocketchat", "enabled": True, "status": "ON for everyone"},
-    {"id": 3, "name": "Wordpress", "enabled": False, "status": "ON for everyone"}
-]
-
-APP_DATA = {"id": 1, "name": "Nextcloud", "selected": True, "status": "ON for everyone", "config": CONFIG_DATA},
-
 @api_v1.route('/apps', methods=['GET'])
 @jwt_required()
 @cross_origin()
diff --git a/areas/apps/models.py b/areas/apps/models.py
index 511c443a..71cedf48 100644
--- a/areas/apps/models.py
+++ b/areas/apps/models.py
@@ -172,26 +172,6 @@ class App(db.Model):
         """Returns the kustomization object for this app"""
         return k8s.get_kustomization(self.slug)
 
-    @staticmethod
-    def check_condition(status):
-        """
-        Returns a tuple that has true/false for readiness and a message
-
-        Ready, in this case means that the condition's type == "Ready" and its
-        status == "True". If the condition type "Ready" does not occur, the
-        status is interpreted as not ready.
-
-        The message that is returned is the message that comes with the
-        condition with type "Ready"
-
-        :param status: Kubernetes resource's "status" object.
-        :type status: dict
-        """
-        for condition in status["conditions"]:
-            if condition["type"] == "Ready":
-                return condition["status"] == "True", condition["message"]
-        return False, "Condition with type 'Ready' not found"
-
     def to_json(self):
         """
         represent this object as a json object. Return JSON object
diff --git a/helpers/kubernetes.py b/helpers/kubernetes.py
index 280cceaf..9a8bdbde 100644
--- a/helpers/kubernetes.py
+++ b/helpers/kubernetes.py
@@ -114,6 +114,29 @@ def get_kubernetes_secret_data(secret_name, namespace):
     return secret
 
 
+def get_kubernetes_config_map_data(config_map_name, namespace):
+    """
+    Get ConfigMap from Kubernetes
+
+    :param config_map_name: Name of the ConfigMap
+    :type config_map_name: string
+    :param namespace: Namespace of the ConfigMap
+    :type namespace: string
+
+    :return: The contents of a kubernetes ConfigMap or None if the cm does not exist.
+    :rtype: dict or None
+    """
+    api_instance = client.CoreV1Api()
+    try:
+        config_map = api_instance.read_namespaced_config_map(config_map_name, namespace).data
+    except ApiException as ex:
+        # 404 is expected when the optional secret does not exist.
+        if ex.status != 404:
+            raise ex
+        return None
+    return config_map
+
+
 def store_kubernetes_secret(secret_dict, namespace, update=False):
     """
     Stores either a new secret in the cluster, or updates an existing one.
-- 
GitLab