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-auth ::mon/mon-auth)
|
||||
|
||||
(def config? (s/keys :req-un [::taiga/taigas]
|
||||
:opt-un [::taiga/issuer
|
||||
::taiga/volume-size
|
||||
::mon-cfg]))
|
||||
; ToDo
|
||||
(def config? (s/keys :req-un
|
||||
:opt-un [::mon-cfg]))
|
||||
|
||||
(def auth? (s/keys :req-un [::taiga/auth]
|
||||
; ToDo
|
||||
(def auth? (s/keys :req-un
|
||||
:opt-un [::mon-auth]))
|
||||
|
||||
(defn-spec sort-config cp/map-or-seq?
|
||||
[unsorted-config config?]
|
||||
(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)))))))
|
||||
; ToDo:
|
||||
(defn generate-configs [config auth])
|
||||
|
||||
(defn-spec k8s-objects cp/map-or-seq?
|
||||
[config config?
|
||||
|
|
|
@ -13,60 +13,17 @@
|
|||
[dda.c4k-common.ingress :as ing]
|
||||
[clojure.string :as str]))
|
||||
|
||||
(defn fqdn-list?
|
||||
[input]
|
||||
(every? true? (map pred/fqdn-string? input)))
|
||||
|
||||
(s/def ::unique-name string?)
|
||||
(s/def ::sha256sum-output string?)
|
||||
; ToDo
|
||||
(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
|
||||
::fqdns
|
||||
::gitea-host
|
||||
::gitea-repo
|
||||
::branchname]
|
||||
:opt-un [::issuer
|
||||
::volume-size
|
||||
::sha256sum-output
|
||||
::build-cpu-request
|
||||
::build-cpu-limit
|
||||
::build-memory-request
|
||||
::build-memory-limit]))
|
||||
; ToDo
|
||||
(def config? (s/keys :req-un
|
||||
:opt-un ))
|
||||
|
||||
(def websiteauth? (s/keys :req-un [::unique-name ::username ::authtoken]))
|
||||
|
||||
(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
|
||||
(def auth? (s/keys :req-un ))
|
||||
|
||||
; ToDo
|
||||
(defn-spec replace-dots-by-minus string?
|
||||
[fqdn pred/fqdn-string?]
|
||||
(str/replace fqdn #"\." "-"))
|
||||
|
|
Loading…
Reference in a new issue