refactore websites -> websiteconfigs
This commit is contained in:
parent
f16ee34782
commit
20401c20b7
6 changed files with 21 additions and 21 deletions
|
@ -24,7 +24,7 @@ For the example configuration
|
|||
|
||||
```yaml
|
||||
issuer: "staging"
|
||||
websites:
|
||||
websiteconfigs:
|
||||
- unique-name: "test.io"
|
||||
fqdns: ["test.de", "test.org", "www.test.de", "www.test.org"]
|
||||
forgejo-host: "codeberg.org"
|
||||
|
|
|
@ -39,10 +39,10 @@
|
|||
::build-memory-request
|
||||
::build-memory-limit]))
|
||||
(def websiteauth? (s/keys :req-un [::unique-name ::username ::authtoken]))
|
||||
(s/def ::websites (s/coll-of websiteconfig?))
|
||||
(s/def ::websiteconfigs (s/coll-of websiteconfig?))
|
||||
(s/def ::auth (s/coll-of websiteauth?))
|
||||
|
||||
(def config? (s/keys :req-un [::websites]
|
||||
(def config? (s/keys :req-un [::websiteconfigs]
|
||||
:opt-un [::issuer
|
||||
::volume-size
|
||||
::mon-cfg]))
|
||||
|
@ -62,9 +62,9 @@
|
|||
|
||||
(defn-spec sort-config map?
|
||||
[unsorted-config config?]
|
||||
(let [sorted-websites (into [] (sort-by :unique-name (unsorted-config :websites)))]
|
||||
(let [sorted-websiteconfigs (into [] (sort-by :unique-name (unsorted-config :websiteconfigs)))]
|
||||
(-> unsorted-config
|
||||
(assoc-in [:websites] sorted-websites))))
|
||||
(assoc-in [:websiteconfigs] sorted-websiteconfigs))))
|
||||
|
||||
(defn-spec sort-auth map?
|
||||
[unsorted-auth auth?]
|
||||
|
@ -75,7 +75,7 @@
|
|||
(defn-spec flatten-and-reduce-config map?
|
||||
[config config?]
|
||||
(let
|
||||
[first-entry (first (:websites config))]
|
||||
[first-entry (first (:websiteconfigs config))]
|
||||
(conj first-entry
|
||||
(when (contains? config :issuer)
|
||||
{:issuer (config :issuer)})
|
||||
|
@ -103,11 +103,11 @@
|
|||
sorted-auth (sort-auth auth)
|
||||
result []]
|
||||
|
||||
(if (and (empty? (config :websites)) (empty? (sorted-auth :auth)))
|
||||
(if (and (empty? (config :websiteconfigs)) (empty? (sorted-auth :auth)))
|
||||
result
|
||||
(recur (->
|
||||
config
|
||||
(assoc-in [:websites] (rest (config :websites))))
|
||||
(assoc-in [:websiteconfigs] (rest (config :websiteconfigs))))
|
||||
(->
|
||||
auth
|
||||
(assoc-in [:auth] (rest (sorted-auth :auth))))
|
||||
|
|
|
@ -46,11 +46,11 @@
|
|||
|
||||
(def websiteauth? (s/keys :req-un [::unique-name ::username ::authtoken]))
|
||||
|
||||
(s/def ::websites (s/coll-of websiteconfig?))
|
||||
(s/def ::websiteconfigs (s/coll-of websiteconfig?))
|
||||
|
||||
(s/def ::auth (s/coll-of websiteauth?))
|
||||
|
||||
(def websites? (s/keys :req-un [::websites]))
|
||||
(def websiteconfigs? (s/keys :req-un [::websiteconfigs]))
|
||||
|
||||
(def auth? (s/keys :req-un [::auth]))
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
(br/generate-group
|
||||
"website-data"
|
||||
(br/generate-text-area
|
||||
"websites" "Contains fqdns, repo infos, an optional sha256sum-output for script execution for each website:"
|
||||
"{ :websites
|
||||
"websiteconfigs" "Contains fqdns, repo infos, an optional sha256sum-output for script execution for each website:"
|
||||
"{ :websiteconfigs
|
||||
[{:unique-name \"test.io\",
|
||||
:fqdns [\"test.de\" \"www.test.de\"],
|
||||
:gitea-host \"githost.de\",
|
||||
|
@ -70,12 +70,12 @@
|
|||
|
||||
(defn config-from-document []
|
||||
(let [issuer (br/get-content-from-element "issuer" :optional true)
|
||||
websites (br/get-content-from-element "websites" :deserializer edn/read-string)
|
||||
websiteconfigs (br/get-content-from-element "websiteconfigs" :deserializer edn/read-string)
|
||||
mon-cluster-name (br/get-content-from-element "mon-cluster-name" :optional true)
|
||||
mon-cluster-stage (br/get-content-from-element "mon-cluster-stage" :optional true)
|
||||
mon-cloud-url (br/get-content-from-element "mon-cloud-url" :optional true)]
|
||||
(merge
|
||||
{:websites websites}
|
||||
{:websiteconfigs websiteconfigs}
|
||||
(when (not (st/blank? issuer))
|
||||
{:issuer issuer})
|
||||
(when (some? mon-cluster-name)
|
||||
|
@ -84,7 +84,7 @@
|
|||
:grafana-cloud-url mon-cloud-url}}))))
|
||||
|
||||
(defn validate-all! []
|
||||
(br/validate! "websites" website/websites? :deserializer edn/read-string)
|
||||
(br/validate! "websiteconfigs" website/websiteconfigs? :deserializer edn/read-string)
|
||||
(br/validate! "issuer" ::website/issuer :optional true)
|
||||
(br/validate! "mon-cluster-name" ::mon/cluster-name :optional true)
|
||||
(br/validate! "mon-cluster-stage" ::mon/cluster-stage :optional true)
|
||||
|
@ -108,7 +108,7 @@
|
|||
core/config-defaults
|
||||
core/k8s-objects)
|
||||
(br/set-output!)))))
|
||||
(add-validate-listener "websites")
|
||||
(add-validate-listener "websiteconfigs")
|
||||
(add-validate-listener "issuer")
|
||||
(add-validate-listener "mon-cluster-name")
|
||||
(add-validate-listener "mon-cluster-stage")
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
(is (s/valid? cut/auth? (yaml/load-as-edn "website-test/valid-auth.yaml"))))
|
||||
|
||||
(def websites1
|
||||
{:websites
|
||||
{:websiteconfigs
|
||||
[{:unique-name "example.io"
|
||||
:fqdns ["example.org", "www.example.com"]
|
||||
:forgejo-host "finegitehost.net"
|
||||
|
@ -39,7 +39,7 @@
|
|||
:branchname "main"}]})
|
||||
|
||||
(def websites2
|
||||
{:websites
|
||||
{:websiteconfigs
|
||||
[{:unique-name "test.io"
|
||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"]
|
||||
:forgejo-host "gitlab.de"
|
||||
|
@ -83,7 +83,7 @@
|
|||
|
||||
(deftest sorts-config
|
||||
(is (= {:issuer "staging",
|
||||
:websites
|
||||
:websiteconfigs
|
||||
[{:unique-name "example.io",
|
||||
:fqdns ["example.org" "www.example.com"],
|
||||
:forgejo-host "finegitehost.net",
|
||||
|
@ -98,7 +98,7 @@
|
|||
:mon-cfg {:grafana-cloud-url "url-for-your-prom-remote-write-endpoint", :cluster-name "jitsi", :cluster-stage "test"}}
|
||||
(cut/sort-config
|
||||
{:issuer "staging",
|
||||
:websites
|
||||
:websiteconfigs
|
||||
[{:unique-name "test.io",
|
||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
||||
:forgejo-host "gitlab.de",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
issuer: "staging"
|
||||
websites:
|
||||
websiteconfigs:
|
||||
- unique-name: "test.io"
|
||||
fqdns: ["test.de", "test.org", "www.test.de", "www.test.org"]
|
||||
forgejo-host: "codeberg.org"
|
||||
|
|
Loading…
Reference in a new issue