refactor to separate config & auth

This commit is contained in:
Michael Jerger 2024-08-02 17:16:46 +02:00
parent 8f714c3bdd
commit d4fb8ca9e2
4 changed files with 43 additions and 32 deletions

View file

@ -5,7 +5,7 @@
:url "https://www.apache.org/licenses/LICENSE-2.0.html"}
:dependencies [[org.clojure/clojure "1.11.3"]
[org.clojure/tools.reader "1.4.2"]
[org.domaindrivenarchitecture/c4k-common-clj "7.0.0"]
[org.domaindrivenarchitecture/c4k-common-clj "8.0.0"]
[hickory "0.7.1" :exclusions [viebel/codox-klipse-theme]]]
:target-path "target/%s/"
:source-paths ["src/main/cljc"

View file

@ -4,7 +4,7 @@
"src/test/cljc"
"src/test/cljs"
"src/test/resources"]
:dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "6.3.1"]
:dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "8.0.0"]
[hickory "0.7.1"]]
:builds {:frontend {:target :browser
:modules {:main {:init-fn dda.c4k-jitsi.browser/init}}

View file

@ -5,10 +5,11 @@
[dda.c4k-jitsi.core :as core]))
(defn -main [& cmd-args]
(uberjar/main-common
"c4k-jitsi"
core/config?
(uberjar/main-cm
"c4k-jitsi"
core/config?
core/auth?
core/config-defaults
core/k8s-objects
core/config-defaults
core/config-objects
core/auth-objects
cmd-args))

View file

@ -1,14 +1,14 @@
(ns dda.c4k-jitsi.core
(:require
[clojure.spec.alpha :as s]
#?(:clj [orchestra.core :refer [defn-spec]]
:cljs [orchestra.core :refer-macros [defn-spec]])
[dda.c4k-common.common :as cm]
[dda.c4k-common.predicate :as cp]
[dda.c4k-common.monitoring :as mon]
[dda.c4k-common.yaml :as yaml]
[dda.c4k-jitsi.jitsi :as jitsi]
[dda.c4k-common.namespace :as ns]))
(:require
[clojure.spec.alpha :as s]
#?(:clj [orchestra.core :refer [defn-spec]]
:cljs [orchestra.core :refer-macros [defn-spec]])
[dda.c4k-common.common :as cm]
[dda.c4k-common.predicate :as cp]
[dda.c4k-common.monitoring :as mon]
[dda.c4k-common.yaml :as yaml]
[dda.c4k-jitsi.jitsi :as jitsi]
[dda.c4k-common.namespace :as ns]))
(def config-defaults {:issuer "staging", :namespace "jitsi"})
@ -24,25 +24,35 @@
::jitsi/jicofo-component-secret]
:opt-un [::mon-auth]))
(defn-spec k8s-objects cp/map-or-seq?
(defn-spec config-objects cp/map-or-seq?
[config config?]
(map yaml/to-string
(filter
#(not (nil? %))
(cm/concat-vec
(ns/generate config)
[(jitsi/generate-jvb-service config)
(jitsi/generate-web-service config)
(jitsi/generate-etherpad-service config)
(jitsi/generate-excalidraw-backend-service config)
(jitsi/generate-meapp-fullstack-service config)
(jitsi/generate-deployment config)
(jitsi/generate-excalidraw-deployment config)
(jitsi/generate-meapp-deployment config)]
(jitsi/generate-ingress-web config)
(jitsi/generate-ingress-etherpad config)
(jitsi/generate-ingress-meapp-fullstack config)
(when (:contains? config :mon-cfg)
(mon/generate-config))))))
(defn-spec auth-objects cp/map-or-seq?
[config config?
auth auth?]
(map yaml/to-string
(filter
#(not (nil? %))
(cm/concat-vec
[(ns/generate config)
(jitsi/generate-secret-jitsi auth)
(jitsi/generate-jvb-service)
(jitsi/generate-web-service)
(jitsi/generate-etherpad-service)
(jitsi/generate-excalidraw-backend-service)
(jitsi/generate-meapp-fullstack-service)
(jitsi/generate-deployment config)
(jitsi/generate-excalidraw-deployment)
(jitsi/generate-meapp-deployment)]
(jitsi/generate-ingress-web config)
(jitsi/generate-ingress-etherpad config)
(jitsi/generate-ingress-meapp-fullstack config)
[(jitsi/generate-secret-jitsi config auth)]
(when (:contains? config :mon-cfg)
(mon/generate-config (:mon-cfg config) (:mon-auth auth)))))))
(mon/generate-auth (:mon-cfg config) (:mon-auth auth)))))))