Add todos, clean superfloous code
This commit is contained in:
parent
2525b51cf6
commit
b89301d194
2 changed files with 14 additions and 104 deletions
|
@ -15,63 +15,16 @@
|
||||||
(s/def ::mon-cfg ::mon/mon-cfg)
|
(s/def ::mon-cfg ::mon/mon-cfg)
|
||||||
(s/def ::mon-auth ::mon/mon-auth)
|
(s/def ::mon-auth ::mon/mon-auth)
|
||||||
|
|
||||||
(def config? (s/keys :req-un [::taiga/taigas]
|
; ToDo
|
||||||
:opt-un [::taiga/issuer
|
(def config? (s/keys :req-un
|
||||||
::taiga/volume-size
|
:opt-un [::mon-cfg]))
|
||||||
::mon-cfg]))
|
|
||||||
|
|
||||||
(def auth? (s/keys :req-un [::taiga/auth]
|
; ToDo
|
||||||
|
(def auth? (s/keys :req-un
|
||||||
:opt-un [::mon-auth]))
|
:opt-un [::mon-auth]))
|
||||||
|
|
||||||
(defn-spec sort-config cp/map-or-seq?
|
; ToDo:
|
||||||
[unsorted-config config?]
|
(defn generate-configs [config auth])
|
||||||
(let [sorted-taigas (into [] (sort-by :unique-name (unsorted-config :taigas)))]
|
|
||||||
(-> unsorted-config
|
|
||||||
(assoc-in [:taigas] sorted-taigas))))
|
|
||||||
|
|
||||||
(defn-spec sort-auth cp/map-or-seq?
|
|
||||||
[unsorted-auth auth?]
|
|
||||||
(let [sorted-auth (into [] (sort-by :unique-name (unsorted-auth :auth)))]
|
|
||||||
(-> unsorted-auth
|
|
||||||
(assoc-in [:auth] sorted-auth))))
|
|
||||||
|
|
||||||
(defn-spec flatten-and-reduce-config cp/map-or-seq?
|
|
||||||
[config config?]
|
|
||||||
(let
|
|
||||||
[first-entry (first (:taigas config))]
|
|
||||||
(conj first-entry
|
|
||||||
(when (contains? config :issuer)
|
|
||||||
{:issuer (config :issuer)})
|
|
||||||
(when (contains? config :volume-size)
|
|
||||||
{:volume-size (config :volume-size)}))))
|
|
||||||
|
|
||||||
(defn-spec flatten-and-reduce-auth cp/map-or-seq?
|
|
||||||
[auth auth?]
|
|
||||||
(-> auth :auth first))
|
|
||||||
|
|
||||||
(defn generate-configs [config auth]
|
|
||||||
(loop [config (sort-config config)
|
|
||||||
auth (sort-auth auth)
|
|
||||||
result []]
|
|
||||||
|
|
||||||
(if (and (empty? (config :taigas)) (empty? (auth :auth)))
|
|
||||||
result
|
|
||||||
(recur (->
|
|
||||||
config
|
|
||||||
(assoc-in [:taigas] (rest (config :taigas))))
|
|
||||||
(->
|
|
||||||
auth
|
|
||||||
(assoc-in [:auth] (rest (auth :auth))))
|
|
||||||
(conj result
|
|
||||||
(taiga/generate-nginx-deployment (flatten-and-reduce-config config))
|
|
||||||
(taiga/generate-nginx-configmap (flatten-and-reduce-config config))
|
|
||||||
(taiga/generate-nginx-service (flatten-and-reduce-config config))
|
|
||||||
(taiga/generate-taiga-content-volume (flatten-and-reduce-config config))
|
|
||||||
(taiga/generate-hashfile-volume (flatten-and-reduce-config config))
|
|
||||||
(taiga/generate-taiga-ingress (flatten-and-reduce-config config))
|
|
||||||
(taiga/generate-taiga-certificate (flatten-and-reduce-config config))
|
|
||||||
(taiga/generate-taiga-build-cron (flatten-and-reduce-config config))
|
|
||||||
(taiga/generate-taiga-build-secret (flatten-and-reduce-config config) (flatten-and-reduce-auth auth)))))))
|
|
||||||
|
|
||||||
(defn-spec k8s-objects cp/map-or-seq?
|
(defn-spec k8s-objects cp/map-or-seq?
|
||||||
[config config?
|
[config config?
|
||||||
|
|
|
@ -13,60 +13,17 @@
|
||||||
[dda.c4k-common.ingress :as ing]
|
[dda.c4k-common.ingress :as ing]
|
||||||
[clojure.string :as str]))
|
[clojure.string :as str]))
|
||||||
|
|
||||||
(defn fqdn-list?
|
; ToDo
|
||||||
[input]
|
|
||||||
(every? true? (map pred/fqdn-string? input)))
|
|
||||||
|
|
||||||
(s/def ::unique-name string?)
|
|
||||||
(s/def ::sha256sum-output string?)
|
|
||||||
(s/def ::issuer pred/letsencrypt-issuer?)
|
(s/def ::issuer pred/letsencrypt-issuer?)
|
||||||
(s/def ::volume-size pred/integer-string?)
|
|
||||||
(s/def ::authtoken pred/bash-env-string?)
|
|
||||||
(s/def ::fqdns (s/coll-of pred/fqdn-string?))
|
|
||||||
(s/def ::gitea-host pred/fqdn-string?)
|
|
||||||
(s/def ::gitea-repo string?)
|
|
||||||
(s/def ::branchname string?)
|
|
||||||
(s/def ::username string?)
|
|
||||||
(s/def ::build-cpu-request string?)
|
|
||||||
(s/def ::build-memory-request string?)
|
|
||||||
(s/def ::build-cpu-limit string?)
|
|
||||||
(s/def ::build-memory-limit string?)
|
|
||||||
|
|
||||||
(def websiteconfig? (s/keys :req-un [::unique-name
|
; ToDo
|
||||||
::fqdns
|
(def config? (s/keys :req-un
|
||||||
::gitea-host
|
:opt-un ))
|
||||||
::gitea-repo
|
|
||||||
::branchname]
|
|
||||||
:opt-un [::issuer
|
|
||||||
::volume-size
|
|
||||||
::sha256sum-output
|
|
||||||
::build-cpu-request
|
|
||||||
::build-cpu-limit
|
|
||||||
::build-memory-request
|
|
||||||
::build-memory-limit]))
|
|
||||||
|
|
||||||
(def websiteauth? (s/keys :req-un [::unique-name ::username ::authtoken]))
|
; ToDo
|
||||||
|
(def auth? (s/keys :req-un ))
|
||||||
(s/def ::websites (s/coll-of websiteconfig?))
|
|
||||||
|
|
||||||
(s/def ::auth (s/coll-of websiteauth?))
|
|
||||||
|
|
||||||
(def websites? (s/keys :req-un [::websites]))
|
|
||||||
|
|
||||||
(def auth? (s/keys :req-un [::auth]))
|
|
||||||
|
|
||||||
(defn-spec get-hash-from-sha256sum-output string?
|
|
||||||
[sha256sum-output string?]
|
|
||||||
(if (nil? sha256sum-output)
|
|
||||||
nil
|
|
||||||
(first (str/split sha256sum-output #"\ +"))))
|
|
||||||
|
|
||||||
(defn-spec get-file-name-from-sha256sum-output string?
|
|
||||||
[sha256sum-output string?]
|
|
||||||
(if (nil? sha256sum-output)
|
|
||||||
nil
|
|
||||||
(second (str/split (str/trim sha256sum-output) #"\ +"))))
|
|
||||||
|
|
||||||
|
; ToDo
|
||||||
(defn-spec replace-dots-by-minus string?
|
(defn-spec replace-dots-by-minus string?
|
||||||
[fqdn pred/fqdn-string?]
|
[fqdn pred/fqdn-string?]
|
||||||
(str/replace fqdn #"\." "-"))
|
(str/replace fqdn #"\." "-"))
|
||||||
|
|
Loading…
Reference in a new issue