From 0fa71e48403519e2383ad7d8b1367df5ad833619 Mon Sep 17 00:00:00 2001
From: Michael Jerger <michael.jerger@meissa-gmbh.de>
Date: Mon, 17 Feb 2025 15:51:17 +0100
Subject: [PATCH] add excalidraw

---
 src/main/cljc/dda/c4k_jitsi/core.cljc         |  3 +-
 src/main/cljc/dda/c4k_jitsi/jitsi.cljc        | 14 +---
 .../jitsi/excalidraw-config-deployment.yaml   | 20 +++++
 .../jitsi/excalidraw-config-service.yaml      | 14 ++++
 src/test/cljc/dda/c4k_jitsi/jitsi_test.cljc   | 74 ++-----------------
 5 files changed, 46 insertions(+), 79 deletions(-)
 create mode 100644 src/main/resources/jitsi/excalidraw-config-deployment.yaml
 create mode 100644 src/main/resources/jitsi/excalidraw-config-service.yaml

diff --git a/src/main/cljc/dda/c4k_jitsi/core.cljc b/src/main/cljc/dda/c4k_jitsi/core.cljc
index 535cb7b..91cb32e 100644
--- a/src/main/cljc/dda/c4k_jitsi/core.cljc
+++ b/src/main/cljc/dda/c4k_jitsi/core.cljc
@@ -40,7 +40,8 @@
            (jitsi/web-config resolved-config)
            (jitsi/jvb-config resolved-config)
            (jitsi/jibri-config resolved-config)
-           (jitsi/etherpad resolved-config)
+           (jitsi/etherpad-config resolved-config)
+           (jitsi/excalidraw-config resolved-config)
            (ing/generate-ingress-and-cert (merge
                                            {:service-name "jitsi-meet-web"
                                             :service-port 80
diff --git a/src/main/cljc/dda/c4k_jitsi/jitsi.cljc b/src/main/cljc/dda/c4k_jitsi/jitsi.cljc
index 6d0e39b..9545d16 100644
--- a/src/main/cljc/dda/c4k_jitsi/jitsi.cljc
+++ b/src/main/cljc/dda/c4k_jitsi/jitsi.cljc
@@ -123,12 +123,11 @@
     [(load-and-adjust-namespace "jitsi/etherpad-config-service.yaml" namespace)
      (load-and-adjust-namespace "jitsi/etherpad-config-deployment.yaml" namespace)]))
 
-(defn-spec generate-excalidraw-backend-service cp/map-or-seq?
+(defn-spec excalidraw-config cp/map-or-seq?
   [config config?]
   (let [{:keys [namespace]} config]
-    (->
-     (yaml/load-as-edn "jitsi/excalidraw-backend-service.yaml")
-     (cm/replace-all-matching "NAMESPACE" namespace))))
+    [(load-and-adjust-namespace "jitsi/excalidraw-config-service.yaml" namespace)
+     (load-and-adjust-namespace "jitsi/excalidraw-config-deployment.yaml" namespace)]))
 
 (defn-spec generate-modelector-service cp/map-or-seq?
   [config config?]
@@ -137,13 +136,6 @@
      (yaml/load-as-edn "jitsi/modelector-service.yaml")
      (cm/replace-all-matching "NAMESPACE" namespace))))
 
-(defn-spec generate-excalidraw-deployment cp/map-or-seq?
-  [config config?]
-  (let [{:keys [fqdn namespace]} config]
-    (->
-     (yaml/load-as-edn "jitsi/excalidraw-deployment.yaml")
-     (cm/replace-all-matching "NAMESPACE" namespace))))
-
 (defn-spec generate-modelector-deployment cp/map-or-seq?
   [config config?]
   (let [{:keys [fqdn namespace]} config]
diff --git a/src/main/resources/jitsi/excalidraw-config-deployment.yaml b/src/main/resources/jitsi/excalidraw-config-deployment.yaml
new file mode 100644
index 0000000..54a65ca
--- /dev/null
+++ b/src/main/resources/jitsi/excalidraw-config-deployment.yaml
@@ -0,0 +1,20 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: excalidraw
+  namespace: NAMESPACE
+  labels:
+    app.kubernetes.io/name: excalidraw
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+      app.kubernetes.io/name: excalidraw
+  template:
+    metadata:
+      labels:
+        app.kubernetes.io/name: excalidraw
+    spec:
+      containers:
+        - name: excalidraw-backend
+          image: domaindrivenarchitecture/c4k-jitsi-excalidraw-backend
\ No newline at end of file
diff --git a/src/main/resources/jitsi/excalidraw-config-service.yaml b/src/main/resources/jitsi/excalidraw-config-service.yaml
new file mode 100644
index 0000000..0ac4be3
--- /dev/null
+++ b/src/main/resources/jitsi/excalidraw-config-service.yaml
@@ -0,0 +1,14 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: excalidraw-backend
+  namespace: NAMESPACE
+  labels:
+    app.kubernetes.io/name: excalidraw  
+spec:
+  ports:
+  - name: excalidraw-backend
+    port: 3002
+    targetPort: 80
+  selector:
+    app.kubernetes.io/name: excalidraw 
\ No newline at end of file
diff --git a/src/test/cljc/dda/c4k_jitsi/jitsi_test.cljc b/src/test/cljc/dda/c4k_jitsi/jitsi_test.cljc
index 074ea09..d99f446 100644
--- a/src/test/cljc/dda/c4k_jitsi/jitsi_test.cljc
+++ b/src/test/cljc/dda/c4k_jitsi/jitsi_test.cljc
@@ -12,73 +12,7 @@
 (st/instrument `cut/web-config)
 (st/instrument `cut/jvb-config)
 (st/instrument `cut/etherpad-config)
-
-(deftest should-generate-excalidraw-backend-service
-  (is (= {:apiVersion "v1",
-          :kind "Service",
-          :metadata
-          {:labels {:service "excalidraw-backend"},
-           :name "excalidraw-backend",
-           :namespace "jitsi"},
-          :spec
-          {:ports [{:name "excalidraw-backend", :port 3002, :targetPort 80}],
-           :selector {:app "excalidraw-backend"}}}
-         (cut/generate-excalidraw-backend-service
-          {:fqdn "xy.xy.xy"
-           :namespace "jitsi"}))))
-
-(deftest should-generate-modelector-service
-  (is (= {:apiVersion "v1",
-          :kind "Service",
-          :metadata
-          {:labels {:service "modelector"},
-           :name "modelector",
-           :namespace "jitsi"},
-          :spec
-          {:ports [{:name "http", :port 80, :targetPort 8080}],
-           :selector {:app "modelector"}}}
-         (cut/generate-modelector-service
-          {:fqdn "xy.xy.xy"
-           :namespace "jitsi"}))))
-
-(deftest should-generate-modelector-deployment
-  (is (= {:apiVersion "apps/v1",
-          :kind "Deployment",
-          :metadata
-          {:labels {:app "modelector"},
-           :name "modelector",
-           :namespace "jitsi"},
-          :spec
-          {:selector {:matchLabels {:app "modelector"}},
-           :replicas 1,
-           :strategy {:type "Recreate"},
-           :template
-           {:metadata {:labels {:app "modelector"}},
-            :spec
-            {:containers
-             [{:name "modelector",
-               :image "domaindrivenarchitecture/moderator-election-vaadin_fullstack",
-               :imagePullPolicy "IfNotPresent",
-               :env
-               [{:name "MEMBERNAMES",
-                 :value "Micha,Ansgar,Erik,Mirco"}]}]}}}}
-          (cut/generate-modelector-deployment
-           {:fqdn "xy.xy.xy"
-            :namespace "jitsi"}))))
-
-(deftest should-generate-excalidraw-deployment
-  (is (= {:apiVersion "v1",
-          :kind "Service",
-          :metadata
-          {:labels {:service "excalidraw-backend"},
-           :name "excalidraw-backend",
-           :namespace "jitsi"},
-          :spec
-          {:ports [{:name "excalidraw-backend", :port 3002, :targetPort 80}],
-           :selector {:app "excalidraw-backend"}}}
-         (cut/generate-excalidraw-backend-service
-          {:fqdn "xy.xy.xy"
-           :namespace "jitsi"}))))
+(st/instrument `cut/excalidraw-config)
 
 (deftest should-generate-prosody
   (is (= {:apiVersion "v1",
@@ -165,3 +99,9 @@
                  {:fqdn "xy.xy.xy"
                   :namespace "jitsi"})))))
 
+(deftest should-generate-excalidraw
+  (is (= 2
+         (count (cut/excalidraw-config
+                 {:fqdn "xy.xy.xy"
+                  :namespace "jitsi"})))))
+