Update core for common uberjar
This commit is contained in:
parent
4a6030f053
commit
d369fdcd91
1 changed files with 30 additions and 25 deletions
|
@ -1,41 +1,46 @@
|
||||||
(ns dda.c4k-keycloak.core
|
(ns dda.c4k-keycloak.core
|
||||||
(:require
|
(:require
|
||||||
[clojure.string :as cs]
|
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
#?(:clj [orchestra.core :refer [defn-spec]]
|
#?(:clj [orchestra.core :refer [defn-spec]]
|
||||||
:cljs [orchestra.core :refer-macros [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-common.yaml :as yaml]
|
||||||
[dda.c4k-common.postgres :as postgres]
|
[dda.c4k-common.postgres :as postgres]
|
||||||
[dda.c4k-keycloak.keycloak :as kc]))
|
[dda.c4k-keycloak.keycloak :as kc]))
|
||||||
|
|
||||||
(def default-storage-class :local-path)
|
(def default-storage-class :local-path)
|
||||||
|
|
||||||
(def config-defaults {:issuer :staging})
|
(def config-defaults {:issuer "staging"})
|
||||||
|
|
||||||
(def config? (s/keys :req-un [::fqdn]
|
(s/def ::mon-cfg mon/config?)
|
||||||
:opt-un [::issuer]))
|
(s/def ::mon-auth mon/auth?)
|
||||||
|
|
||||||
(def auth? (s/keys :req-un [::kc/keycloak-admin-user ::kc/keycloak-admin-password]))
|
(def config? (s/keys :req-un [::kc/fqdn]
|
||||||
|
:opt-un [::kc/issuer
|
||||||
|
::mon-cfg]))
|
||||||
|
|
||||||
(defn-spec k8s-objects any?
|
(def auth? (s/keys :req-un [::kc/keycloak-admin-user ::kc/keycloak-admin-password
|
||||||
|
::postgres/postgres-db-user ::postgres/postgres-db-password]
|
||||||
|
:opt-un [::mon-auth]))
|
||||||
|
|
||||||
|
(defn-spec k8s-objects cp/map-or-seq?
|
||||||
[config config?
|
[config config?
|
||||||
auth auth?]
|
auth auth?]
|
||||||
(into
|
(map yaml/to-string
|
||||||
[]
|
(filter
|
||||||
(concat [(yaml/to-string (postgres/generate-config {:postgres-size :2gb :db-name "keycloak"}))
|
#(not (nil? %))
|
||||||
(yaml/to-string (postgres/generate-secret auth))
|
(cm/concat-vec
|
||||||
(yaml/to-string (postgres/generate-pvc {:pv-storage-size-gb 30
|
[(postgres/generate-config {:postgres-size :2gb :db-name "keycloak"})
|
||||||
:pvc-storage-class-name default-storage-class}))
|
(postgres/generate-secret auth)
|
||||||
(yaml/to-string (postgres/generate-deployment :postgres-image "postgres:14"))
|
(postgres/generate-pvc {:pv-storage-size-gb 30
|
||||||
(yaml/to-string (postgres/generate-service))
|
:pvc-storage-class-name default-storage-class})
|
||||||
(yaml/to-string (kc/generate-secret auth))
|
(postgres/generate-deployment :postgres-image "postgres:14")
|
||||||
(yaml/to-string (kc/generate-ingress config))
|
(postgres/generate-service)
|
||||||
(yaml/to-string (kc/generate-service))
|
(kc/generate-secret auth)
|
||||||
(yaml/to-string (kc/generate-deployment))])))
|
(kc/generate-service)
|
||||||
|
(kc/generate-deployment)]
|
||||||
(defn-spec generate any?
|
(kc/generate-ingress config)
|
||||||
[my-config config?
|
(when (:contains? config :mon-cfg)
|
||||||
my-auth auth?]
|
(mon/generate (:mon-cfg config) (:mon-auth auth)))))))
|
||||||
(cs/join
|
|
||||||
"\n---\n"
|
|
||||||
(k8s-objects my-config my-auth)))
|
|
||||||
|
|
Loading…
Reference in a new issue