[WIP] Solve ToDos
* Hardened flatten-and-reduce-config through sorting of :auth and :website vectors * add issuer kv and volume-size kv only when existing in config * fixed test in website_test.cljc * fixed content-vol-creation for nonexistent volume-size kv pair
This commit is contained in:
parent
5bcfe9f0b1
commit
caa8b5c886
4 changed files with 16 additions and 7 deletions
|
@ -8,11 +8,19 @@
|
|||
(def config-defaults {:issuer "staging"
|
||||
:volume-size "3"})
|
||||
|
||||
; TODO: gec 2022/10/28: That does only work if the :websites and :auth collections have the same order regarding :unique-name!
|
||||
; There must be a check or the config must be sorted first!
|
||||
(defn flatten-and-reduce-config
|
||||
[config]
|
||||
(merge (-> config :websites first) (-> config :auth first) (dissoc config :websites :auth)))
|
||||
[unsorted-config]
|
||||
(let [sorted-websites (into [] (sort-by :unique-name (unsorted-config :websites)))
|
||||
sorted-auth (into [] (sort-by :unique-name (unsorted-config :auth)))
|
||||
config (-> unsorted-config
|
||||
(assoc-in [:websites] sorted-websites)
|
||||
(assoc-in [:auth] sorted-auth))]
|
||||
(merge (-> config :websites first)
|
||||
(-> config :auth first)
|
||||
(when (contains? config :issuer)
|
||||
{:issuer (config :issuer)})
|
||||
(when (contains? config :volume-size)
|
||||
{:volume-size (config :volume-size)}))))
|
||||
|
||||
; TODO: Find a better readable expression.
|
||||
(defn generate-configs [config]
|
||||
|
|
|
@ -152,7 +152,8 @@
|
|||
|
||||
(defn-spec generate-website-content-volume pred/map-or-seq?
|
||||
[config websitedata?]
|
||||
(let [{:keys [unique-name volume-size]} config]
|
||||
(let [{:keys [unique-name volume-size]
|
||||
:or {volume-size "3"}} config]
|
||||
(->
|
||||
(yaml/load-as-edn "website/website-content-volume.yaml")
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (replace-dots-by-minus unique-name))
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
:branchname "main"}]}))))
|
||||
|
||||
(deftest should-generate-nginx-configmap-website
|
||||
(is (= "server {\n listen 80 default_server;\n listen [::]:80 default_server;\n listen 443 ssl;\n ssl_certificate /etc/certs/tls.crt;\n ssl_certificate_key /etc/certs/tls.key;\n server_name test.de www.test.de test-it.de www.test-it.de;\n add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains; preload';\n add_header X-XSS-Protection \"1; mode=block\";\n add_header X-Frame-Options \"SAMEORIGIN\";\n add_header X-Content-Type-Options nosniff;\n add_header Referrer-Policy \"strict-origin\";\n # add_header Permissions-Policy \"permissions here\";\n root /var/www/html/website/;\n index index.html;\n location / {\n try_files $uri $uri/ /index.html =404;\n }\n}\n"
|
||||
(is (= "server {\n listen 80 default_server;\n listen [::]:80 default_server;\n server_name test.de www.test.de test-it.de www.test-it.de;\n add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains; preload';\n add_header X-XSS-Protection \"1; mode=block\";\n add_header X-Frame-Options \"SAMEORIGIN\";\n add_header X-Content-Type-Options nosniff;\n add_header Referrer-Policy \"strict-origin\";\n # add_header Permissions-Policy \"permissions here\";\n root /var/www/html/website/;\n index index.html;\n location / {\n try_files $uri $uri/ /index.html =404;\n }\n}\n"
|
||||
(:website.conf (:data (cut/generate-nginx-configmap {:unique-name "test.io",
|
||||
:gitea-host "gitea.evilorg",
|
||||
:gitea-repo "none",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{:issuer "staging"
|
||||
:websites
|
||||
[{:unique-name "test.io" ; todo: call this unique-name
|
||||
[{:unique-name "test.io"
|
||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"]
|
||||
:gitea-host "gitlab.de"
|
||||
:gitea-repo "repo"
|
||||
|
|
Loading…
Reference in a new issue