add-hugo-build #5

Merged
gec merged 18 commits from add-hugo-build into main 2024-03-15 12:02:22 +00:00
2 changed files with 43 additions and 14 deletions
Showing only changes of commit f1e41b3333 - Show all commits

View file

@ -53,17 +53,17 @@
; https://your.gitea.host/api/v1/repos/<owner>/<repo>/archive/<branch>.zip
(defn-spec generate-gitrepourl string?
[host pred/fqdn-string?
owner string?
repo string?
user string?
branch string?]
(str "https://" host "/api/v1/repos/" user "/" repo "/archive/" branch ".zip"))
(str "https://" host "/api/v1/repos/" owner "/" repo "/archive/" branch ".zip"))
; https://your.gitea.host/api/v1/repos/<owner>/<repo>/git/commits/HEAD
(defn-spec generate-gitcommiturl string?
[host pred/fqdn-string?
repo string?
user string?]
(str "https://" host "/api/v1/repos/" user "/" repo "/git/" "commits/" "HEAD"))
owner string?
repo string?]
(str "https://" host "/api/v1/repos/" owner "/" repo "/git/" "commits/" "HEAD"))
(defn-spec replace-all-matching-prefixes map?
@ -104,7 +104,7 @@
#"REDIRECTS"
(generate-redirects config 2)))))))
; TODO add test & add to build-cron env
; TODO add to build-cron env
(defn-spec generate-build-configmap pred/map-or-seq?
[config websiteconfig?]
(let [{:keys [unique-name
@ -116,17 +116,15 @@
(->
(yaml/load-as-edn "website/build-configmap.yaml")
(replace-all-matching-prefixes "NAME" name)
(cm/replace-all-matching-values-by-new-value "REPOURL" (b64/encode
(generate-gitrepourl
(cm/replace-all-matching-values-by-new-value "REPOURL" (generate-gitrepourl
forgejo-host
forgejo-repo
repo-user
branchname)))
(cm/replace-all-matching-values-by-new-value "COMMITURL" (b64/encode
(generate-gitcommiturl
forgejo-repo
branchname))
(cm/replace-all-matching-values-by-new-value "COMMITURL" (generate-gitcommiturl
forgejo-host
forgejo-repo
repo-user))))))
repo-user
forgejo-repo)))))
(defn-spec generate-build-secret pred/map-or-seq?
[auth websiteauth?]

View file

@ -19,6 +19,14 @@
(st/instrument `cut/generate-nginx-service)
(deftest should-generate-gitrepourl
(is (= "https://mygit.de/api/v1/repos/someuser/repo/archive/main.zip"
(cut/generate-gitrepourl "mygit.de" "someuser" "repo" "main"))))
(deftest should-generate-gitcommiturl
(is (= "https://mygit.de/api/v1/repos/someuser/repo/git/commits/HEAD"
(cut/generate-gitcommiturl "mygit.de" "someuser" "repo"))))
(deftest should-generate-redirects
(is (= "rewrite ^/products.html\\$ /offer.html permanent;\n rewrite ^/one-more\\$ /redirect permanent;"
(cut/generate-redirects {:issuer "staging"
@ -220,6 +228,29 @@
:unique-name "test.io",
:redirects []}))))
(deftest should-generate-build-configmap
(is (= {:apiVersion "v1",
:kind "ConfigMap",
:metadata {:name "build-configmap",
:namespace "test-io",
:labels {:app.kubernetes.part-of "test-io-website"}},
:data
{:GITREPOURL "https://mygit.de/api/v1/repos/someuser/repo/archive/main.zip"
:GITCOMMITURL "https://mygit.de/api/v1/repos/someuser/repo/git/commits/HEAD"}}
(cut/generate-build-configmap {:issuer "staging"
:build-cpu-request "500m"
:build-cpu-limit "1700m"
:build-memory-request "256Mi"
:build-memory-limit "512Mi"
:volume-size "3"
:forgejo-host "mygit.de",
:repo-user "someuser",
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
:forgejo-repo "repo",
:branchname "main",
:unique-name "test.io",
:redirects []}))))
(deftest should-generate-build-secret
(is (= {:apiVersion "v1",
:kind "Secret",