added basic yaml-generation
This commit is contained in:
parent
0580d50755
commit
eb5cbda3b5
2 changed files with 102 additions and 0 deletions
35
src/main/cljc/dda/c4k_jitsi/core.cljc
Normal file
35
src/main/cljc/dda/c4k_jitsi/core.cljc
Normal file
|
@ -0,0 +1,35 @@
|
|||
(ns dda.c4k-jitsi.core
|
||||
(:require
|
||||
[clojure.string :as cs]
|
||||
[clojure.spec.alpha :as s]
|
||||
#?(:clj [orchestra.core :refer [defn-spec]]
|
||||
:cljs [orchestra.core :refer-macros [defn-spec]])
|
||||
[dda.c4k-common.yaml :as yaml]
|
||||
[dda.c4k-jitsi.jitsi :as jitsi]))
|
||||
|
||||
(def config-defaults {:issuer :staging})
|
||||
|
||||
(def config? (s/keys :req-un [::jitsi/fqdn]
|
||||
:opt-un [::jitsi/issuer ::jitsi/ingress-type]))
|
||||
|
||||
(def auth? (s/keys :req-un []))
|
||||
|
||||
(defn k8s-objects [config]
|
||||
map yaml/to-string
|
||||
[(jitsi/generate-jicofo-deployment config)
|
||||
(jitsi/generate-jicofo-pvc)
|
||||
(jitsi/generate-jvb-deployment config)
|
||||
(jitsi/generate-jvb-pvc)
|
||||
(jitsi/generate-jvb-service)
|
||||
(jitsi/generate-networkpolicy)
|
||||
(jitsi/generate-prosody-deployment config)
|
||||
(jitsi/generate-prosody-pvc)
|
||||
(jitsi/generate-prosody-service)])
|
||||
|
||||
(defn-spec generate any?
|
||||
[my-config config?
|
||||
my-auth auth?]
|
||||
(let [resulting-config (merge config-defaults my-config my-auth)]
|
||||
(cs/join
|
||||
"\n---\n"
|
||||
(k8s-objects resulting-config))))
|
67
src/main/cljc/dda/c4k_jitsi/jitsi.cljc
Normal file
67
src/main/cljc/dda/c4k_jitsi/jitsi.cljc
Normal file
|
@ -0,0 +1,67 @@
|
|||
(ns dda.c4k-jitsi.jitsi
|
||||
(:require
|
||||
[clojure.spec.alpha :as s]
|
||||
#?(:cljs [shadow.resource :as rc])
|
||||
[dda.c4k-common.yaml :as yaml]
|
||||
[dda.c4k-common.common :as cm]
|
||||
[dda.c4k-common.predicate :as pred]))
|
||||
|
||||
(s/def ::fqdn pred/fqdn-string?)
|
||||
(s/def ::issuer pred/letsencrypt-issuer?)
|
||||
|
||||
#?(:cljs
|
||||
(defmethod yaml/load-resource :jitsi [resource-name]
|
||||
(case resource-name
|
||||
"jitsi/jicofo-deployment.yaml" (rc/inline "jitsi/jicofo-deployment.yaml")
|
||||
"jitsi/jicofo-pvc.yaml" (rc/inline "jitsi/jicofo-pvc.yaml")
|
||||
"jitsi/jvb-deployment.yaml" (rc/inline "jitsi/jvb-deployment.yaml")
|
||||
"jitsi/jvb-pvc.yaml" (rc/inline "jitsi/jvb-pvc.yaml")
|
||||
"jitsi/jvb-service.yaml" (rc/inline "jitsi/jvb-service.yaml")
|
||||
"jitsi/networkpolicy.yaml" (rc/inline "jitsi/networkpolicy.yaml")
|
||||
"jitsi/prosody-deployment.yaml" (rc/inline "jitsi/prosody-deployment.yaml")
|
||||
"jitsi/prosody-pvc.yaml" (rc/inline "jitsi/prosody-pvc.yaml")
|
||||
"jitsi/prosody-service.yaml" (rc/inline "jitsi/prosody-service.yaml")
|
||||
"jitsi/web-deployment.yaml" (rc/inline "jitsi/web-deployment.yaml")
|
||||
"jitsi/web-pvc.yaml" (rc/inline "jitsi/web-pvc.yaml")
|
||||
"jitsi/web-service.yaml" (rc/inline "jitsi/web-service.yaml")
|
||||
(throw (js/Error. "Undefined Resource!")))))
|
||||
|
||||
(defn generate-jicofo-deployment [config]
|
||||
(->
|
||||
(yaml/from-string (yaml/load-resource "jitsi/jicofo-deployment.yaml"))))
|
||||
|
||||
(defn generate-jicofo-pvc []
|
||||
(yaml/from-string (yaml/load-resource "jitsi/jicofo-pvc.yaml")))
|
||||
|
||||
(defn generate-jvb-deployment [config]
|
||||
(->
|
||||
(yaml/from-string (yaml/load-resource "jitsi/jvb-deployment.yaml"))))
|
||||
|
||||
(defn generate-jvb-pvc []
|
||||
(yaml/from-string (yaml/load-resource "jitsi/jvb-pvc.yaml")))
|
||||
|
||||
(defn generate-jvb-service []
|
||||
(yaml/from-string (yaml/load-resource "jitsi/jvb-service.yaml")))
|
||||
|
||||
(defn generate-networkpolicy []
|
||||
(yaml/from-string (yaml/load-resource "jitsi/networkpolicy.yaml")))
|
||||
|
||||
(defn generate-prosody-deployment [config]
|
||||
(->
|
||||
(yaml/from-string (yaml/load-resource "jitsi/prosody-deployment.yaml"))))
|
||||
|
||||
(defn generate-prosody-pvc []
|
||||
(yaml/from-string (yaml/load-resource "jitsi/prosody-pvc.yaml")))
|
||||
|
||||
(defn generate-prosody-service []
|
||||
(yaml/from-string (yaml/load-resource "jitsi/prosody-service.yaml")))
|
||||
|
||||
(defn generate-web-deployment [config]
|
||||
(->
|
||||
(yaml/from-string (yaml/load-resource "jitsi/web-deployment.yaml"))))
|
||||
|
||||
(defn generate-web-pvc []
|
||||
(yaml/from-string (yaml/load-resource "jitsi/web-pvc.yaml")))
|
||||
|
||||
(defn generate-web-service []
|
||||
(yaml/from-string (yaml/load-resource "jitsi/web-service.yaml")))
|
Loading…
Reference in a new issue