small adjustments
This commit is contained in:
parent
e923c9d5c3
commit
e02f4949fc
3 changed files with 16 additions and 22 deletions
|
@ -16,6 +16,7 @@
|
||||||
(s/def ::unique-name ::web/unique-name)
|
(s/def ::unique-name ::web/unique-name)
|
||||||
(s/def ::issuer ::web/issuer)
|
(s/def ::issuer ::web/issuer)
|
||||||
(s/def ::volume-size ::web/volume-size)
|
(s/def ::volume-size ::web/volume-size)
|
||||||
|
|
||||||
(s/def ::authtoken ::web/authtoken)
|
(s/def ::authtoken ::web/authtoken)
|
||||||
(s/def ::fqdns ::web/fqdns)
|
(s/def ::fqdns ::web/fqdns)
|
||||||
(s/def ::forgejo-host ::web/forgejo-host)
|
(s/def ::forgejo-host ::web/forgejo-host)
|
||||||
|
@ -26,7 +27,6 @@
|
||||||
(s/def ::build-memory-request ::web/build-memory-request)
|
(s/def ::build-memory-request ::web/build-memory-request)
|
||||||
(s/def ::build-cpu-limit ::web/build-cpu-limit)
|
(s/def ::build-cpu-limit ::web/build-cpu-limit)
|
||||||
(s/def ::build-memory-limit ::web/build-memory-limit)
|
(s/def ::build-memory-limit ::web/build-memory-limit)
|
||||||
(s/def ::redirect ::web/redirect)
|
|
||||||
(s/def ::redirects ::web/redirects)
|
(s/def ::redirects ::web/redirects)
|
||||||
|
|
||||||
(def websiteconfig? (s/keys :req-un [::unique-name
|
(def websiteconfig? (s/keys :req-un [::unique-name
|
||||||
|
@ -42,7 +42,9 @@
|
||||||
::build-memory-request
|
::build-memory-request
|
||||||
::build-memory-limit
|
::build-memory-limit
|
||||||
::redirects]))
|
::redirects]))
|
||||||
(def websiteauth? (s/keys :req-un [::unique-name ::authtoken]))
|
(def websiteauth? web/websiteauth?)
|
||||||
|
(def websiteauths? (s/keys :req-un [::websiteauths]))
|
||||||
|
|
||||||
(s/def ::websiteconfigs (s/coll-of websiteconfig?))
|
(s/def ::websiteconfigs (s/coll-of websiteconfig?))
|
||||||
(s/def ::websiteauths (s/coll-of websiteauth?))
|
(s/def ::websiteauths (s/coll-of websiteauth?))
|
||||||
|
|
||||||
|
@ -76,6 +78,7 @@
|
||||||
(-> unsorted-auth
|
(-> unsorted-auth
|
||||||
(assoc-in [:websiteauths] sorted-auth))))
|
(assoc-in [:websiteauths] sorted-auth))))
|
||||||
|
|
||||||
|
; TODO: Replace this with a function that merges defaults into website config
|
||||||
(defn-spec flatten-and-reduce-config map?
|
(defn-spec flatten-and-reduce-config map?
|
||||||
[config config?]
|
[config config?]
|
||||||
(let
|
(let
|
||||||
|
@ -103,22 +106,22 @@
|
||||||
(defn-spec generate seq?
|
(defn-spec generate seq?
|
||||||
[config config?
|
[config config?
|
||||||
auth auth?]
|
auth auth?]
|
||||||
(loop [config (sort-config config)
|
(loop [sorted-config (sort-config config)
|
||||||
sorted-auth (sort-auth auth)
|
sorted-auth (sort-auth auth)
|
||||||
result []]
|
result []]
|
||||||
|
|
||||||
(if (and (empty? (config :websiteconfigs)) (empty? (sorted-auth :websiteauths)))
|
(if (and (empty? (sorted-config :websiteconfigs)) (empty? (sorted-auth :websiteauths)))
|
||||||
result
|
result
|
||||||
(recur (->
|
(recur (->
|
||||||
config
|
sorted-config
|
||||||
(assoc-in [:websiteconfigs] (rest (config :websiteconfigs))))
|
(assoc-in [:websiteconfigs] (rest (sorted-config :websiteconfigs))))
|
||||||
(->
|
(->
|
||||||
auth
|
sorted-auth
|
||||||
(assoc-in [:websiteauths] (rest (sorted-auth :websiteauths))))
|
(assoc-in [:websiteauths] (rest (sorted-auth :websiteauths))))
|
||||||
(let [final-config
|
(let [final-config
|
||||||
(merge
|
(merge
|
||||||
website-config-defaults
|
website-config-defaults
|
||||||
(flatten-and-reduce-config config))
|
(flatten-and-reduce-config sorted-config))
|
||||||
name (web/replace-dots-by-minus (:unique-name final-config))]
|
name (web/replace-dots-by-minus (:unique-name final-config))]
|
||||||
(cm/concat-vec
|
(cm/concat-vec
|
||||||
result
|
result
|
||||||
|
|
|
@ -30,31 +30,22 @@
|
||||||
(s/def ::redirect (s/tuple string? string?))
|
(s/def ::redirect (s/tuple string? string?))
|
||||||
(s/def ::redirects (s/coll-of ::redirect))
|
(s/def ::redirects (s/coll-of ::redirect))
|
||||||
|
|
||||||
; TODO: is this websiteconfig? & websiteauth? used or the ones in core?
|
|
||||||
(def websiteconfig? (s/keys :req-un [::unique-name
|
(def websiteconfig? (s/keys :req-un [::unique-name
|
||||||
::fqdns
|
::fqdns
|
||||||
::forgejo-host
|
::forgejo-host
|
||||||
::repo-user
|
::repo-user
|
||||||
::forgejo-repo
|
::forgejo-repo
|
||||||
::branchname
|
::branchname
|
||||||
::issuer
|
|
||||||
::volume-size
|
|
||||||
::build-cpu-request
|
::build-cpu-request
|
||||||
::build-cpu-limit
|
::build-cpu-limit
|
||||||
::build-memory-request
|
::build-memory-request
|
||||||
::build-memory-limit
|
::build-memory-limit
|
||||||
|
::issuer
|
||||||
|
::volume-size
|
||||||
::redirects]))
|
::redirects]))
|
||||||
|
|
||||||
(def websiteauth? (s/keys :req-un [::unique-name ::authtoken]))
|
(def websiteauth? (s/keys :req-un [::unique-name ::authtoken]))
|
||||||
|
|
||||||
(s/def ::websiteconfigs (s/coll-of websiteconfig?))
|
|
||||||
|
|
||||||
(s/def ::websiteauths (s/coll-of websiteauth?))
|
|
||||||
|
|
||||||
(def websiteconfigs? (s/keys :req-un [::websiteconfigs]))
|
|
||||||
|
|
||||||
(def auth? (s/keys :req-un [::websiteauths]))
|
|
||||||
|
|
||||||
(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 #"\." "-"))
|
||||||
|
|
|
@ -84,12 +84,12 @@
|
||||||
:grafana-cloud-url mon-cloud-url}}))))
|
:grafana-cloud-url mon-cloud-url}}))))
|
||||||
|
|
||||||
(defn validate-all! []
|
(defn validate-all! []
|
||||||
(br/validate! "websiteconfigs" website/websiteconfigs? :deserializer edn/read-string)
|
(br/validate! "websiteconfigs" core/websiteconfigs? :deserializer edn/read-string)
|
||||||
(br/validate! "issuer" ::website/issuer :optional true)
|
(br/validate! "issuer" ::core/issuer :optional true)
|
||||||
(br/validate! "mon-cluster-name" ::mon/cluster-name :optional true)
|
(br/validate! "mon-cluster-name" ::mon/cluster-name :optional true)
|
||||||
(br/validate! "mon-cluster-stage" ::mon/cluster-stage :optional true)
|
(br/validate! "mon-cluster-stage" ::mon/cluster-stage :optional true)
|
||||||
(br/validate! "mon-cloud-url" ::mon/grafana-cloud-url :optional true)
|
(br/validate! "mon-cloud-url" ::mon/grafana-cloud-url :optional true)
|
||||||
(br/validate! "auth" website/auth? :deserializer edn/read-string)
|
(br/validate! "auth" core/websiteauths? :deserializer edn/read-string)
|
||||||
(br/set-form-validated!))
|
(br/set-form-validated!))
|
||||||
|
|
||||||
(defn add-validate-listener [name]
|
(defn add-validate-listener [name]
|
||||||
|
|
Loading…
Reference in a new issue