|
|
@ -5,15 +5,27 @@
|
|
|
|
:cljs [orchestra.core :refer-macros [defn-spec]])
|
|
|
|
:cljs [orchestra.core :refer-macros [defn-spec]])
|
|
|
|
[dda.c4k-common.yaml :as yaml]
|
|
|
|
[dda.c4k-common.yaml :as yaml]
|
|
|
|
[dda.c4k-common.common :as cm]
|
|
|
|
[dda.c4k-common.common :as cm]
|
|
|
|
[dda.c4k-common.predicate :as pred]
|
|
|
|
[dda.c4k-common.predicate :as cp]
|
|
|
|
|
|
|
|
[dda.c4k-common.monitoring :as mon]
|
|
|
|
[dda.c4k-website.website :as website]))
|
|
|
|
[dda.c4k-website.website :as website]))
|
|
|
|
|
|
|
|
|
|
|
|
(def config-defaults {:issuer "staging"
|
|
|
|
(def config-defaults {:issuer "staging"
|
|
|
|
:volume-size "3"})
|
|
|
|
:volume-size "3"})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(s/def ::mon-cfg mon/config?)
|
|
|
|
|
|
|
|
(s/def ::mon-auth mon/auth?)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(def config? (s/keys :req-un [::website/websites]
|
|
|
|
|
|
|
|
:opt-un [::website/issuer
|
|
|
|
|
|
|
|
::website/volume-size
|
|
|
|
|
|
|
|
::mon-cfg]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(def auth? (s/keys :req-un [::website/auth]
|
|
|
|
|
|
|
|
:opt-un [::mon-auth]))
|
|
|
|
|
|
|
|
|
|
|
|
(def merged-config-and-auth? (s/and website/config? website/auth?))
|
|
|
|
(def merged-config-and-auth? (s/and website/config? website/auth?))
|
|
|
|
|
|
|
|
|
|
|
|
(defn-spec sort-config pred/map-or-seq?
|
|
|
|
(defn-spec sort-config cp/map-or-seq?
|
|
|
|
[unsorted-config merged-config-and-auth?]
|
|
|
|
[unsorted-config merged-config-and-auth?]
|
|
|
|
(let [sorted-websites (into [] (sort-by :unique-name (unsorted-config :websites)))
|
|
|
|
(let [sorted-websites (into [] (sort-by :unique-name (unsorted-config :websites)))
|
|
|
|
sorted-auth (into [] (sort-by :unique-name (unsorted-config :auth)))]
|
|
|
|
sorted-auth (into [] (sort-by :unique-name (unsorted-config :auth)))]
|
|
|
@ -21,7 +33,7 @@
|
|
|
|
(assoc-in [:websites] sorted-websites)
|
|
|
|
(assoc-in [:websites] sorted-websites)
|
|
|
|
(assoc-in [:auth] sorted-auth))))
|
|
|
|
(assoc-in [:auth] sorted-auth))))
|
|
|
|
|
|
|
|
|
|
|
|
(defn-spec flatten-and-reduce-config pred/map-or-seq?
|
|
|
|
(defn-spec flatten-and-reduce-config cp/map-or-seq?
|
|
|
|
[config merged-config-and-auth?]
|
|
|
|
[config merged-config-and-auth?]
|
|
|
|
(merge (-> config :websites first)
|
|
|
|
(merge (-> config :websites first)
|
|
|
|
(-> config :auth first)
|
|
|
|
(-> config :auth first)
|
|
|
@ -51,8 +63,14 @@
|
|
|
|
(website/generate-website-build-cron (flatten-and-reduce-config config))
|
|
|
|
(website/generate-website-build-cron (flatten-and-reduce-config config))
|
|
|
|
(website/generate-website-build-secret (flatten-and-reduce-config config)))))))
|
|
|
|
(website/generate-website-build-secret (flatten-and-reduce-config config)))))))
|
|
|
|
|
|
|
|
|
|
|
|
(defn k8s-objects [config]
|
|
|
|
(defn-spec k8s-objects cp/map-or-seq?
|
|
|
|
|
|
|
|
[config config?
|
|
|
|
|
|
|
|
auth auth?]
|
|
|
|
(cm/concat-vec
|
|
|
|
(cm/concat-vec
|
|
|
|
(map yaml/to-string
|
|
|
|
(map yaml/to-string
|
|
|
|
(filter #(not (nil? %))
|
|
|
|
(filter
|
|
|
|
(generate-configs config)))))
|
|
|
|
#(not (nil? %))
|
|
|
|
|
|
|
|
(cm/concat-vec
|
|
|
|
|
|
|
|
(generate-configs (merge config auth))
|
|
|
|
|
|
|
|
(when (:contains? config :mon-cfg)
|
|
|
|
|
|
|
|
(mon/generate (:mon-cfg config) (:mon-auth auth))))))))
|
|
|
|