feature/introduce-redirects #4

Merged
jem merged 4 commits from feature/introduce-redirects into main 2024-02-28 09:29:10 +00:00
4 changed files with 38 additions and 38 deletions
Showing only changes of commit 3a216d52df - Show all commits

View file

@ -67,10 +67,10 @@
[(website/generate-nginx-deployment (flatten-and-reduce-config config))
(website/generate-nginx-configmap (flatten-and-reduce-config config))
(website/generate-nginx-service (flatten-and-reduce-config config))
(website/generate-website-content-volume (flatten-and-reduce-config config))
(website/generate-hashfile-volume (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-content-pvc (flatten-and-reduce-config config))
(website/generate-hash-state-pvc (flatten-and-reduce-config config))
(website/generate-build-cron (flatten-and-reduce-config config))
(website/generate-build-secret (flatten-and-reduce-config config)
(flatten-and-reduce-auth auth))]
(website/generate-ingress (flatten-and-reduce-config config))
)))))

View file

@ -64,32 +64,32 @@
(int/generate-nginx-service final-config)))
(defn-spec generate-website-content-volume map?
(defn-spec generate-content-pvc map?
[config websiteconfig?]
(let [final-config (merge config-defaults
config)]
(int/generate-website-content-volume final-config)))
(int/generate-content-pvc final-config)))
(defn-spec generate-hashfile-volume map?
(defn-spec generate-hash-state-pvc map?
[config websiteconfig?]
(let [final-config (merge config-defaults
config)]
(int/generate-hashfile-volume final-config)))
(int/generate-hash-state-pvc final-config)))
(defn-spec generate-website-build-cron map?
(defn-spec generate-build-cron map?
[config websiteconfig?]
(let [final-config (merge config-defaults
config)]
(int/generate-website-build-cron final-config)))
(int/generate-build-cron final-config)))
(defn-spec generate-website-build-secret map?
(defn-spec generate-build-secret map?
[config websiteconfig?
auth websiteauth?]
(let [final-config (merge config-defaults
config)]
(int/generate-website-build-secret final-config auth)))
(int/generate-build-secret final-config auth)))
(defn-spec generate-namespcae seq?
[config websiteconfig?]

View file

@ -73,8 +73,8 @@
user string?]
(str "https://" host "/api/v1/repos/" user "/" repo "/git/" "commits/" "HEAD"))
; TODO: Rename replace-all-matching-prefixes
(defn-spec replace-all-matching-substrings-beginning-with map?
(defn-spec replace-all-matching-prefixes map?
[col map?
value-to-partly-match string?
value-to-inplace string?]
@ -101,7 +101,7 @@
name (replace-dots-by-minus unique-name)]
(->
(yaml/load-as-edn "website/nginx-configmap.yaml")
(replace-all-matching-substrings-beginning-with "NAME" name)
(replace-all-matching-prefixes "NAME" name)
(#(assoc-in % [:data :website.conf]
(str/replace
(-> % :data :website.conf)
@ -114,7 +114,7 @@
(generate-redirects config 2)))))))
(defn-spec generate-website-build-secret pred/map-or-seq?
(defn-spec generate-build-secret pred/map-or-seq?
[config websiteconfig?
auth websiteauth?]
(let [{:keys [unique-name
@ -126,7 +126,7 @@
name (replace-dots-by-minus unique-name)]
(->
(yaml/load-as-edn "website/build-secret.yaml")
(replace-all-matching-substrings-beginning-with "NAME" name)
(replace-all-matching-prefixes "NAME" name)
(cm/replace-all-matching-values-by-new-value "TOKEN" (b64/encode authtoken))
(cm/replace-all-matching-values-by-new-value "REPOURL" (b64/encode
(generate-gitrepourl
@ -141,24 +141,24 @@
username))))))
(defn-spec generate-website-content-volume map?
(defn-spec generate-content-pvc map?
[config websiteconfig?]
(let [{:keys [unique-name volume-size]} config
name (replace-dots-by-minus unique-name)]
(->
(yaml/load-as-edn "website/content-pvc.yaml")
(replace-all-matching-substrings-beginning-with "NAME" name)
(replace-all-matching-prefixes "NAME" name)
(cm/replace-all-matching-values-by-new-value "WEBSITESTORAGESIZE" (str volume-size "Gi")))))
; TODO: Non-Secret-Parts should be config map
(defn-spec generate-hashfile-volume map?
(defn-spec generate-hash-state-pvc map?
[config websiteconfig?]
(let [{:keys [unique-name]} config
name (replace-dots-by-minus unique-name)]
(->
(yaml/load-as-edn "website/hash-state-pvc.yaml")
(replace-all-matching-substrings-beginning-with "NAME" name))))
(replace-all-matching-prefixes "NAME" name))))
(defn-spec generate-nginx-deployment map?
@ -169,21 +169,21 @@
(->
(yaml/load-as-edn "website/nginx-deployment.yaml")
(assoc-in [:metadata :namespace] name)
(replace-all-matching-substrings-beginning-with "NAME" name)
(replace-all-matching-prefixes "NAME" name)
(cm/replace-all-matching-values-by-new-value "BUILD_CPU_REQUEST" build-cpu-request)
(cm/replace-all-matching-values-by-new-value "BUILD_CPU_LIMIT" build-cpu-limit)
(cm/replace-all-matching-values-by-new-value "BUILD_MEMORY_REQUEST" build-memory-request)
(cm/replace-all-matching-values-by-new-value "BUILD_MEMORY_LIMIT" build-memory-limit))))
(defn-spec generate-website-build-cron map?
(defn-spec generate-build-cron map?
[config websiteconfig?]
(let [{:keys [unique-name build-cpu-request build-cpu-limit build-memory-request
build-memory-limit]} config
name (replace-dots-by-minus unique-name)]
(->
(yaml/load-as-edn "website/build-cron.yaml")
(replace-all-matching-substrings-beginning-with "NAME" name)
(replace-all-matching-prefixes "NAME" name)
(cm/replace-all-matching-values-by-new-value "BUILD_CPU_REQUEST" build-cpu-request)
(cm/replace-all-matching-values-by-new-value "BUILD_CPU_LIMIT" build-cpu-limit)
(cm/replace-all-matching-values-by-new-value "BUILD_MEMORY_REQUEST" build-memory-request)
@ -197,7 +197,7 @@
(->
(yaml/load-as-edn "website/nginx-service.yaml")
(assoc-in [:metadata :namespace] name)
(replace-all-matching-substrings-beginning-with "NAME" name))))
(replace-all-matching-prefixes "NAME" name))))
#?(:cljs

View file

@ -8,13 +8,13 @@
(st/instrument `cut/replace-dots-by-minus)
(st/instrument `cut/generate-gitrepourl)
(st/instrument `cut/generate-gitcommiturl)
(st/instrument `cut/replace-all-matching-substrings-beginning-with)
(st/instrument `cut/replace-all-matching-prefixes)
(st/instrument `cut/generate-redirects)
(st/instrument `cut/generate-nginx-configmap)
(st/instrument `cut/generate-website-build-secret)
(st/instrument `cut/generate-website-content-volume)
(st/instrument `cut/generate-hashfile-volume)
(st/instrument `cut/generate-website-build-cron)
(st/instrument `cut/generate-build-secret)
(st/instrument `cut/generate-content-pvc)
(st/instrument `cut/generate-hash-state-pvc)
(st/instrument `cut/generate-build-cron)
(st/instrument `cut/generate-nginx-service)
(deftest should-generate-redirects
@ -162,7 +162,7 @@
)))
(deftest should-generate-website-build-cron
(deftest should-generate-build-cron
(is (= {:apiVersion "batch/v1",
:kind "CronJob",
:metadata {:name "build-cron",
@ -192,7 +192,7 @@
:volumes [{:name "content-volume", :persistentVolumeClaim {:claimName "content-volume"}}
{:name "hash-state-volume", :persistentVolumeClaim {:claimName "hash-state-volume"}}],
:restartPolicy "OnFailure"}}}}}}
(cut/generate-website-build-cron {:issuer "staging"
(cut/generate-build-cron {:issuer "staging"
:build-cpu-request "500m"
:build-cpu-limit "1700m"
:build-memory-request "256Mi"
@ -205,7 +205,7 @@
:unique-name "test.io",
:redirects [],}))))
(deftest should-generate-website-build-secret
(deftest should-generate-build-secret
(is (= {:apiVersion "v1",
:kind "Secret",
:metadata {:name "build-secret",
@ -215,7 +215,7 @@
{:AUTHTOKEN "YWJlZGpnYmFzZG9kag==",
:GITREPOURL "aHR0cHM6Ly9naXRsYWIuZGUvYXBpL3YxL3JlcG9zL3NvbWV1c2VyL3JlcG8vYXJjaGl2ZS9tYWluLnppcA==",
:GITCOMMITURL "aHR0cHM6Ly9naXRsYWIuZGUvYXBpL3YxL3JlcG9zL3NvbWV1c2VyL3JlcG8vZ2l0L2NvbW1pdHMvSEVBRA=="}}
(cut/generate-website-build-secret {:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
(cut/generate-build-secret {:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
:forgejo-repo "repo",
:issuer "staging",
:branchname "main",
@ -231,7 +231,7 @@
:authtoken "abedjgbasdodj",
:username "someuser"}))))
(deftest should-generate-website-content-volume
(deftest should-generate-content-pvc
(is (= {:apiVersion "v1",
:kind "PersistentVolumeClaim",
:metadata
@ -242,7 +242,7 @@
{:storageClassName "local-path",
:accessModes ["ReadWriteOnce"],
:resources {:requests {:storage "3Gi"}}}}
(cut/generate-website-content-volume {:issuer "staging"
(cut/generate-content-pvc {:issuer "staging"
:build-cpu-request "500m"
:build-cpu-limit "1700m"
:build-memory-request "256Mi"
@ -256,7 +256,7 @@
:fqdns ["test.de" "www.test.de" "test-it.de" "www.test-it.de"]}))))
(deftest should-generate-hashfile-volume
(deftest should-generate-hash-state-pvc
(is (= {:apiVersion "v1",
:kind "PersistentVolumeClaim",
:metadata
@ -266,7 +266,7 @@
:spec {:storageClassName "local-path",
:accessModes ["ReadWriteOnce"],
:resources {:requests {:storage "16Mi"}}}}
(cut/generate-hashfile-volume {:issuer "staging"
(cut/generate-hash-state-pvc {:issuer "staging"
:build-cpu-request "500m"
:build-cpu-limit "1700m"
:build-memory-request "256Mi"