From 9e75c22337bf07f4d254d8c6a5b5db07d4e9c957 Mon Sep 17 00:00:00 2001 From: Clemens Date: Thu, 7 Mar 2024 11:26:49 +0100 Subject: [PATCH] added build-configmap generation --- src/main/cljc/dda/c4k_website/core.cljc | 24 +++++++++---------- src/main/cljc/dda/c4k_website/website.cljc | 10 ++++---- src/test/cljc/dda/c4k_website/core_test.cljc | 2 +- .../cljc/dda/c4k_website/website_test.cljc | 15 +----------- 4 files changed, 18 insertions(+), 33 deletions(-) diff --git a/src/main/cljc/dda/c4k_website/core.cljc b/src/main/cljc/dda/c4k_website/core.cljc index 64e4f2d..af5383e 100644 --- a/src/main/cljc/dda/c4k_website/core.cljc +++ b/src/main/cljc/dda/c4k_website/core.cljc @@ -118,23 +118,23 @@ (-> sorted-auth (assoc-in [:websiteauths] (rest (sorted-auth :websiteauths)))) - (let [final-config + (let [curr-flat-websiteconfig (merge website-config-defaults (flatten-and-reduce-config sorted-config)) - name (web/replace-dots-by-minus (:unique-name final-config))] + name (web/replace-dots-by-minus (:unique-name curr-flat-websiteconfig))] (cm/concat-vec result - (ns/generate (merge {:namespace name} final-config)) - [(web/generate-nginx-deployment final-config) - (web/generate-nginx-configmap final-config) - (web/generate-nginx-service final-config) - (web/generate-content-pvc final-config) - (web/generate-hash-state-pvc final-config) - (web/generate-build-cron final-config) - (web/generate-build-secret final-config - (flatten-and-reduce-auth auth))] - (generate-ingress final-config))))))) + (ns/generate (merge {:namespace name} curr-flat-websiteconfig)) + [(web/generate-nginx-deployment curr-flat-websiteconfig) + (web/generate-nginx-configmap curr-flat-websiteconfig) + (web/generate-nginx-service curr-flat-websiteconfig) + (web/generate-content-pvc curr-flat-websiteconfig) + (web/generate-hash-state-pvc curr-flat-websiteconfig) + (web/generate-build-cron curr-flat-websiteconfig) + (web/generate-build-configmap curr-flat-websiteconfig) + (web/generate-build-secret (flatten-and-reduce-auth auth))] + (generate-ingress curr-flat-websiteconfig))))))) (defn-spec k8s-objects cp/map-or-seq? [config config? diff --git a/src/main/cljc/dda/c4k_website/website.cljc b/src/main/cljc/dda/c4k_website/website.cljc index 33746b7..9dd6142 100644 --- a/src/main/cljc/dda/c4k_website/website.cljc +++ b/src/main/cljc/dda/c4k_website/website.cljc @@ -104,7 +104,7 @@ #"REDIRECTS" (generate-redirects config 2))))))) -; TODO add test +; TODO add test & add to build-cron env (defn-spec generate-build-configmap pred/map-or-seq? [config websiteconfig?] (let [{:keys [unique-name @@ -127,12 +127,10 @@ forgejo-host forgejo-repo repo-user)))))) -; TODO: remove config + (defn-spec generate-build-secret pred/map-or-seq? - [config websiteconfig? - auth websiteauth?] - (let [{:keys [unique-name]} config - {:keys [unique-name + [auth websiteauth?] + (let [{:keys [unique-name authtoken]} auth name (replace-dots-by-minus unique-name)] (-> diff --git a/src/test/cljc/dda/c4k_website/core_test.cljc b/src/test/cljc/dda/c4k_website/core_test.cljc index db5e3b5..e028819 100644 --- a/src/test/cljc/dda/c4k_website/core_test.cljc +++ b/src/test/cljc/dda/c4k_website/core_test.cljc @@ -131,7 +131,7 @@ (cut/flatten-and-reduce-auth (cut/sort-auth auth2))))) (deftest test-generate - (is (= 22 + (is (= 24 (count (cut/generate (yaml/load-as-edn "website-test/valid-config.yaml") (yaml/load-as-edn "website-test/valid-auth.yaml")))))) diff --git a/src/test/cljc/dda/c4k_website/website_test.cljc b/src/test/cljc/dda/c4k_website/website_test.cljc index 42a6371..a94dffd 100644 --- a/src/test/cljc/dda/c4k_website/website_test.cljc +++ b/src/test/cljc/dda/c4k_website/website_test.cljc @@ -228,20 +228,7 @@ :labels {:app.kubernetes.part-of "test-io-website"}}, :data {:AUTHTOKEN "YWJlZGpnYmFzZG9kag=="}} - (cut/generate-build-secret {:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"], - :forgejo-repo "repo", - :issuer "staging", - :branchname "main", - :unique-name "test.io", - :redirects [], - :forgejo-host "gitlab.de" - :repo-user "someuser", - :build-cpu-request "500m" - :build-cpu-limit "1700m" - :build-memory-request "256Mi" - :build-memory-limit "512Mi" - :volume-size "3"} - {:unique-name "test.io", + (cut/generate-build-secret {:unique-name "test.io", :authtoken "abedjgbasdodj"})))) (deftest should-generate-content-pvc