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