name refactorings
This commit is contained in:
parent
b4ec6d16b3
commit
3a216d52df
4 changed files with 38 additions and 38 deletions
|
@ -67,10 +67,10 @@
|
||||||
[(website/generate-nginx-deployment (flatten-and-reduce-config config))
|
[(website/generate-nginx-deployment (flatten-and-reduce-config config))
|
||||||
(website/generate-nginx-configmap (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-nginx-service (flatten-and-reduce-config config))
|
||||||
(website/generate-website-content-volume (flatten-and-reduce-config config))
|
(website/generate-content-pvc (flatten-and-reduce-config config))
|
||||||
(website/generate-hashfile-volume (flatten-and-reduce-config config))
|
(website/generate-hash-state-pvc (flatten-and-reduce-config config))
|
||||||
(website/generate-website-build-cron (flatten-and-reduce-config config))
|
(website/generate-build-cron (flatten-and-reduce-config config))
|
||||||
(website/generate-website-build-secret (flatten-and-reduce-config config)
|
(website/generate-build-secret (flatten-and-reduce-config config)
|
||||||
(flatten-and-reduce-auth auth))]
|
(flatten-and-reduce-auth auth))]
|
||||||
(website/generate-ingress (flatten-and-reduce-config config))
|
(website/generate-ingress (flatten-and-reduce-config config))
|
||||||
)))))
|
)))))
|
||||||
|
|
|
@ -64,32 +64,32 @@
|
||||||
(int/generate-nginx-service final-config)))
|
(int/generate-nginx-service final-config)))
|
||||||
|
|
||||||
|
|
||||||
(defn-spec generate-website-content-volume map?
|
(defn-spec generate-content-pvc map?
|
||||||
[config websiteconfig?]
|
[config websiteconfig?]
|
||||||
(let [final-config (merge config-defaults
|
(let [final-config (merge config-defaults
|
||||||
config)]
|
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?]
|
[config websiteconfig?]
|
||||||
(let [final-config (merge config-defaults
|
(let [final-config (merge config-defaults
|
||||||
config)]
|
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?]
|
[config websiteconfig?]
|
||||||
(let [final-config (merge config-defaults
|
(let [final-config (merge config-defaults
|
||||||
config)]
|
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?
|
[config websiteconfig?
|
||||||
auth websiteauth?]
|
auth websiteauth?]
|
||||||
(let [final-config (merge config-defaults
|
(let [final-config (merge config-defaults
|
||||||
config)]
|
config)]
|
||||||
(int/generate-website-build-secret final-config auth)))
|
(int/generate-build-secret final-config auth)))
|
||||||
|
|
||||||
(defn-spec generate-namespcae seq?
|
(defn-spec generate-namespcae seq?
|
||||||
[config websiteconfig?]
|
[config websiteconfig?]
|
||||||
|
|
|
@ -73,8 +73,8 @@
|
||||||
user string?]
|
user string?]
|
||||||
(str "https://" host "/api/v1/repos/" user "/" repo "/git/" "commits/" "HEAD"))
|
(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?
|
[col map?
|
||||||
value-to-partly-match string?
|
value-to-partly-match string?
|
||||||
value-to-inplace string?]
|
value-to-inplace string?]
|
||||||
|
@ -101,7 +101,7 @@
|
||||||
name (replace-dots-by-minus unique-name)]
|
name (replace-dots-by-minus unique-name)]
|
||||||
(->
|
(->
|
||||||
(yaml/load-as-edn "website/nginx-configmap.yaml")
|
(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]
|
(#(assoc-in % [:data :website.conf]
|
||||||
(str/replace
|
(str/replace
|
||||||
(-> % :data :website.conf)
|
(-> % :data :website.conf)
|
||||||
|
@ -114,7 +114,7 @@
|
||||||
(generate-redirects config 2)))))))
|
(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?
|
[config websiteconfig?
|
||||||
auth websiteauth?]
|
auth websiteauth?]
|
||||||
(let [{:keys [unique-name
|
(let [{:keys [unique-name
|
||||||
|
@ -126,7 +126,7 @@
|
||||||
name (replace-dots-by-minus unique-name)]
|
name (replace-dots-by-minus unique-name)]
|
||||||
(->
|
(->
|
||||||
(yaml/load-as-edn "website/build-secret.yaml")
|
(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 "TOKEN" (b64/encode authtoken))
|
||||||
(cm/replace-all-matching-values-by-new-value "REPOURL" (b64/encode
|
(cm/replace-all-matching-values-by-new-value "REPOURL" (b64/encode
|
||||||
(generate-gitrepourl
|
(generate-gitrepourl
|
||||||
|
@ -141,24 +141,24 @@
|
||||||
username))))))
|
username))))))
|
||||||
|
|
||||||
|
|
||||||
(defn-spec generate-website-content-volume map?
|
(defn-spec generate-content-pvc map?
|
||||||
[config websiteconfig?]
|
[config websiteconfig?]
|
||||||
(let [{:keys [unique-name volume-size]} config
|
(let [{:keys [unique-name volume-size]} config
|
||||||
name (replace-dots-by-minus unique-name)]
|
name (replace-dots-by-minus unique-name)]
|
||||||
(->
|
(->
|
||||||
(yaml/load-as-edn "website/content-pvc.yaml")
|
(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")))))
|
(cm/replace-all-matching-values-by-new-value "WEBSITESTORAGESIZE" (str volume-size "Gi")))))
|
||||||
|
|
||||||
|
|
||||||
; TODO: Non-Secret-Parts should be config map
|
; TODO: Non-Secret-Parts should be config map
|
||||||
(defn-spec generate-hashfile-volume map?
|
(defn-spec generate-hash-state-pvc map?
|
||||||
[config websiteconfig?]
|
[config websiteconfig?]
|
||||||
(let [{:keys [unique-name]} config
|
(let [{:keys [unique-name]} config
|
||||||
name (replace-dots-by-minus unique-name)]
|
name (replace-dots-by-minus unique-name)]
|
||||||
(->
|
(->
|
||||||
(yaml/load-as-edn "website/hash-state-pvc.yaml")
|
(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?
|
(defn-spec generate-nginx-deployment map?
|
||||||
|
@ -169,21 +169,21 @@
|
||||||
(->
|
(->
|
||||||
(yaml/load-as-edn "website/nginx-deployment.yaml")
|
(yaml/load-as-edn "website/nginx-deployment.yaml")
|
||||||
(assoc-in [:metadata :namespace] name)
|
(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_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_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_REQUEST" build-memory-request)
|
||||||
(cm/replace-all-matching-values-by-new-value "BUILD_MEMORY_LIMIT" build-memory-limit))))
|
(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?]
|
[config websiteconfig?]
|
||||||
(let [{:keys [unique-name build-cpu-request build-cpu-limit build-memory-request
|
(let [{:keys [unique-name build-cpu-request build-cpu-limit build-memory-request
|
||||||
build-memory-limit]} config
|
build-memory-limit]} config
|
||||||
name (replace-dots-by-minus unique-name)]
|
name (replace-dots-by-minus unique-name)]
|
||||||
(->
|
(->
|
||||||
(yaml/load-as-edn "website/build-cron.yaml")
|
(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_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_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_REQUEST" build-memory-request)
|
||||||
|
@ -197,7 +197,7 @@
|
||||||
(->
|
(->
|
||||||
(yaml/load-as-edn "website/nginx-service.yaml")
|
(yaml/load-as-edn "website/nginx-service.yaml")
|
||||||
(assoc-in [:metadata :namespace] name)
|
(assoc-in [:metadata :namespace] name)
|
||||||
(replace-all-matching-substrings-beginning-with "NAME" name))))
|
(replace-all-matching-prefixes "NAME" name))))
|
||||||
|
|
||||||
|
|
||||||
#?(:cljs
|
#?(:cljs
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
(st/instrument `cut/replace-dots-by-minus)
|
(st/instrument `cut/replace-dots-by-minus)
|
||||||
(st/instrument `cut/generate-gitrepourl)
|
(st/instrument `cut/generate-gitrepourl)
|
||||||
(st/instrument `cut/generate-gitcommiturl)
|
(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-redirects)
|
||||||
(st/instrument `cut/generate-nginx-configmap)
|
(st/instrument `cut/generate-nginx-configmap)
|
||||||
(st/instrument `cut/generate-website-build-secret)
|
(st/instrument `cut/generate-build-secret)
|
||||||
(st/instrument `cut/generate-website-content-volume)
|
(st/instrument `cut/generate-content-pvc)
|
||||||
(st/instrument `cut/generate-hashfile-volume)
|
(st/instrument `cut/generate-hash-state-pvc)
|
||||||
(st/instrument `cut/generate-website-build-cron)
|
(st/instrument `cut/generate-build-cron)
|
||||||
(st/instrument `cut/generate-nginx-service)
|
(st/instrument `cut/generate-nginx-service)
|
||||||
|
|
||||||
(deftest should-generate-redirects
|
(deftest should-generate-redirects
|
||||||
|
@ -162,7 +162,7 @@
|
||||||
)))
|
)))
|
||||||
|
|
||||||
|
|
||||||
(deftest should-generate-website-build-cron
|
(deftest should-generate-build-cron
|
||||||
(is (= {:apiVersion "batch/v1",
|
(is (= {:apiVersion "batch/v1",
|
||||||
:kind "CronJob",
|
:kind "CronJob",
|
||||||
:metadata {:name "build-cron",
|
:metadata {:name "build-cron",
|
||||||
|
@ -192,7 +192,7 @@
|
||||||
:volumes [{:name "content-volume", :persistentVolumeClaim {:claimName "content-volume"}}
|
:volumes [{:name "content-volume", :persistentVolumeClaim {:claimName "content-volume"}}
|
||||||
{:name "hash-state-volume", :persistentVolumeClaim {:claimName "hash-state-volume"}}],
|
{:name "hash-state-volume", :persistentVolumeClaim {:claimName "hash-state-volume"}}],
|
||||||
:restartPolicy "OnFailure"}}}}}}
|
:restartPolicy "OnFailure"}}}}}}
|
||||||
(cut/generate-website-build-cron {:issuer "staging"
|
(cut/generate-build-cron {:issuer "staging"
|
||||||
:build-cpu-request "500m"
|
:build-cpu-request "500m"
|
||||||
:build-cpu-limit "1700m"
|
:build-cpu-limit "1700m"
|
||||||
:build-memory-request "256Mi"
|
:build-memory-request "256Mi"
|
||||||
|
@ -205,7 +205,7 @@
|
||||||
:unique-name "test.io",
|
:unique-name "test.io",
|
||||||
:redirects [],}))))
|
:redirects [],}))))
|
||||||
|
|
||||||
(deftest should-generate-website-build-secret
|
(deftest should-generate-build-secret
|
||||||
(is (= {:apiVersion "v1",
|
(is (= {:apiVersion "v1",
|
||||||
:kind "Secret",
|
:kind "Secret",
|
||||||
:metadata {:name "build-secret",
|
:metadata {:name "build-secret",
|
||||||
|
@ -215,7 +215,7 @@
|
||||||
{:AUTHTOKEN "YWJlZGpnYmFzZG9kag==",
|
{:AUTHTOKEN "YWJlZGpnYmFzZG9kag==",
|
||||||
:GITREPOURL "aHR0cHM6Ly9naXRsYWIuZGUvYXBpL3YxL3JlcG9zL3NvbWV1c2VyL3JlcG8vYXJjaGl2ZS9tYWluLnppcA==",
|
:GITREPOURL "aHR0cHM6Ly9naXRsYWIuZGUvYXBpL3YxL3JlcG9zL3NvbWV1c2VyL3JlcG8vYXJjaGl2ZS9tYWluLnppcA==",
|
||||||
:GITCOMMITURL "aHR0cHM6Ly9naXRsYWIuZGUvYXBpL3YxL3JlcG9zL3NvbWV1c2VyL3JlcG8vZ2l0L2NvbW1pdHMvSEVBRA=="}}
|
: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",
|
:forgejo-repo "repo",
|
||||||
:issuer "staging",
|
:issuer "staging",
|
||||||
:branchname "main",
|
:branchname "main",
|
||||||
|
@ -231,7 +231,7 @@
|
||||||
:authtoken "abedjgbasdodj",
|
:authtoken "abedjgbasdodj",
|
||||||
:username "someuser"}))))
|
:username "someuser"}))))
|
||||||
|
|
||||||
(deftest should-generate-website-content-volume
|
(deftest should-generate-content-pvc
|
||||||
(is (= {:apiVersion "v1",
|
(is (= {:apiVersion "v1",
|
||||||
:kind "PersistentVolumeClaim",
|
:kind "PersistentVolumeClaim",
|
||||||
:metadata
|
:metadata
|
||||||
|
@ -242,7 +242,7 @@
|
||||||
{:storageClassName "local-path",
|
{:storageClassName "local-path",
|
||||||
:accessModes ["ReadWriteOnce"],
|
:accessModes ["ReadWriteOnce"],
|
||||||
:resources {:requests {:storage "3Gi"}}}}
|
:resources {:requests {:storage "3Gi"}}}}
|
||||||
(cut/generate-website-content-volume {:issuer "staging"
|
(cut/generate-content-pvc {:issuer "staging"
|
||||||
:build-cpu-request "500m"
|
:build-cpu-request "500m"
|
||||||
:build-cpu-limit "1700m"
|
:build-cpu-limit "1700m"
|
||||||
:build-memory-request "256Mi"
|
:build-memory-request "256Mi"
|
||||||
|
@ -256,7 +256,7 @@
|
||||||
:fqdns ["test.de" "www.test.de" "test-it.de" "www.test-it.de"]}))))
|
: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",
|
(is (= {:apiVersion "v1",
|
||||||
:kind "PersistentVolumeClaim",
|
:kind "PersistentVolumeClaim",
|
||||||
:metadata
|
:metadata
|
||||||
|
@ -266,7 +266,7 @@
|
||||||
:spec {:storageClassName "local-path",
|
:spec {:storageClassName "local-path",
|
||||||
:accessModes ["ReadWriteOnce"],
|
:accessModes ["ReadWriteOnce"],
|
||||||
:resources {:requests {:storage "16Mi"}}}}
|
:resources {:requests {:storage "16Mi"}}}}
|
||||||
(cut/generate-hashfile-volume {:issuer "staging"
|
(cut/generate-hash-state-pvc {:issuer "staging"
|
||||||
:build-cpu-request "500m"
|
:build-cpu-request "500m"
|
||||||
:build-cpu-limit "1700m"
|
:build-cpu-limit "1700m"
|
||||||
:build-memory-request "256Mi"
|
:build-memory-request "256Mi"
|
||||||
|
|
Loading…
Reference in a new issue