add-hugo-build #5
2 changed files with 43 additions and 14 deletions
|
@ -53,17 +53,17 @@
|
||||||
; https://your.gitea.host/api/v1/repos/<owner>/<repo>/archive/<branch>.zip
|
; https://your.gitea.host/api/v1/repos/<owner>/<repo>/archive/<branch>.zip
|
||||||
(defn-spec generate-gitrepourl string?
|
(defn-spec generate-gitrepourl string?
|
||||||
[host pred/fqdn-string?
|
[host pred/fqdn-string?
|
||||||
|
owner string?
|
||||||
repo string?
|
repo string?
|
||||||
user string?
|
|
||||||
branch 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
|
; https://your.gitea.host/api/v1/repos/<owner>/<repo>/git/commits/HEAD
|
||||||
(defn-spec generate-gitcommiturl string?
|
(defn-spec generate-gitcommiturl string?
|
||||||
[host pred/fqdn-string?
|
[host pred/fqdn-string?
|
||||||
repo string?
|
owner string?
|
||||||
user string?]
|
repo string?]
|
||||||
(str "https://" host "/api/v1/repos/" user "/" repo "/git/" "commits/" "HEAD"))
|
(str "https://" host "/api/v1/repos/" owner "/" repo "/git/" "commits/" "HEAD"))
|
||||||
|
|
||||||
|
|
||||||
(defn-spec replace-all-matching-prefixes map?
|
(defn-spec replace-all-matching-prefixes map?
|
||||||
|
@ -104,7 +104,7 @@
|
||||||
#"REDIRECTS"
|
#"REDIRECTS"
|
||||||
(generate-redirects config 2)))))))
|
(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?
|
(defn-spec generate-build-configmap pred/map-or-seq?
|
||||||
[config websiteconfig?]
|
[config websiteconfig?]
|
||||||
(let [{:keys [unique-name
|
(let [{:keys [unique-name
|
||||||
|
@ -116,17 +116,15 @@
|
||||||
(->
|
(->
|
||||||
(yaml/load-as-edn "website/build-configmap.yaml")
|
(yaml/load-as-edn "website/build-configmap.yaml")
|
||||||
(replace-all-matching-prefixes "NAME" name)
|
(replace-all-matching-prefixes "NAME" name)
|
||||||
(cm/replace-all-matching-values-by-new-value "REPOURL" (b64/encode
|
(cm/replace-all-matching-values-by-new-value "REPOURL" (generate-gitrepourl
|
||||||
(generate-gitrepourl
|
|
||||||
forgejo-host
|
forgejo-host
|
||||||
forgejo-repo
|
|
||||||
repo-user
|
repo-user
|
||||||
branchname)))
|
forgejo-repo
|
||||||
(cm/replace-all-matching-values-by-new-value "COMMITURL" (b64/encode
|
branchname))
|
||||||
(generate-gitcommiturl
|
(cm/replace-all-matching-values-by-new-value "COMMITURL" (generate-gitcommiturl
|
||||||
forgejo-host
|
forgejo-host
|
||||||
forgejo-repo
|
repo-user
|
||||||
repo-user))))))
|
forgejo-repo)))))
|
||||||
|
|
||||||
(defn-spec generate-build-secret pred/map-or-seq?
|
(defn-spec generate-build-secret pred/map-or-seq?
|
||||||
[auth websiteauth?]
|
[auth websiteauth?]
|
||||||
|
|
|
@ -19,6 +19,14 @@
|
||||||
(st/instrument `cut/generate-nginx-service)
|
(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
|
(deftest should-generate-redirects
|
||||||
(is (= "rewrite ^/products.html\\$ /offer.html permanent;\n rewrite ^/one-more\\$ /redirect permanent;"
|
(is (= "rewrite ^/products.html\\$ /offer.html permanent;\n rewrite ^/one-more\\$ /redirect permanent;"
|
||||||
(cut/generate-redirects {:issuer "staging"
|
(cut/generate-redirects {:issuer "staging"
|
||||||
|
@ -220,6 +228,29 @@
|
||||||
:unique-name "test.io",
|
:unique-name "test.io",
|
||||||
:redirects []}))))
|
: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
|
(deftest should-generate-build-secret
|
||||||
(is (= {:apiVersion "v1",
|
(is (= {:apiVersion "v1",
|
||||||
:kind "Secret",
|
:kind "Secret",
|
||||||
|
|
Loading…
Reference in a new issue