add-hugo-build #5
7 changed files with 55 additions and 35 deletions
|
@ -19,17 +19,20 @@
|
|||
(s/def ::authtoken ::web/authtoken)
|
||||
(s/def ::fqdns ::web/fqdns)
|
||||
(s/def ::forgejo-host ::web/forgejo-host)
|
||||
(s/def ::repo-user ::web/repo-user)
|
||||
(s/def ::forgejo-repo ::web/forgejo-repo)
|
||||
(s/def ::branchname ::web/branchname)
|
||||
(s/def ::username ::web/username)
|
||||
(s/def ::build-cpu-request ::web/build-cpu-request)
|
||||
(s/def ::build-memory-request ::web/build-memory-request)
|
||||
(s/def ::build-cpu-limit ::web/build-cpu-limit)
|
||||
(s/def ::build-memory-limit ::web/build-memory-limit)
|
||||
(s/def ::redirect ::web/redirect)
|
||||
(s/def ::redirects ::web/redirects)
|
||||
|
||||
(def websiteconfig? (s/keys :req-un [::unique-name
|
||||
::fqdns
|
||||
::forgejo-host
|
||||
::repo-user
|
||||
::forgejo-repo
|
||||
::branchname]
|
||||
:opt-un [::issuer
|
||||
|
@ -37,8 +40,9 @@
|
|||
::build-cpu-request
|
||||
::build-cpu-limit
|
||||
::build-memory-request
|
||||
::build-memory-limit]))
|
||||
(def websiteauth? (s/keys :req-un [::unique-name ::username ::authtoken]))
|
||||
::build-memory-limit
|
||||
::redirects]))
|
||||
(def websiteauth? (s/keys :req-un [::unique-name ::authtoken]))
|
||||
(s/def ::websiteconfigs (s/coll-of websiteconfig?))
|
||||
(s/def ::websiteauths (s/coll-of websiteauth?))
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
(s/def ::forgejo-host pred/fqdn-string?)
|
||||
(s/def ::forgejo-repo string?)
|
||||
(s/def ::branchname string?)
|
||||
(s/def ::username string?)
|
||||
(s/def ::repo-user string?)
|
||||
(s/def ::build-cpu-request string?)
|
||||
(s/def ::build-memory-request string?)
|
||||
(s/def ::build-cpu-limit string?)
|
||||
|
@ -30,10 +30,11 @@
|
|||
(s/def ::redirect (s/tuple string? string?))
|
||||
(s/def ::redirects (s/coll-of ::redirect))
|
||||
|
||||
|
||||
; TODO: is this websiteconfig? & websiteauth? used or the ones in core?
|
||||
(def websiteconfig? (s/keys :req-un [::unique-name
|
||||
::fqdns
|
||||
::forgejo-host
|
||||
::repo-user
|
||||
::forgejo-repo
|
||||
::branchname
|
||||
::issuer
|
||||
|
@ -44,7 +45,7 @@
|
|||
::build-memory-limit
|
||||
::redirects]))
|
||||
|
||||
(def websiteauth? (s/keys :req-un [::unique-name ::username ::authtoken]))
|
||||
(def websiteauth? (s/keys :req-un [::unique-name ::authtoken]))
|
||||
|
||||
(s/def ::websiteconfigs (s/coll-of websiteconfig?))
|
||||
|
||||
|
@ -112,18 +113,15 @@
|
|||
#"REDIRECTS"
|
||||
(generate-redirects config 2)))))))
|
||||
|
||||
|
||||
|
||||
; TODO generate git path without username
|
||||
; TODO add test
|
||||
(defn-spec generate-build-configmap pred/map-or-seq?
|
||||
[config websiteconfig?]
|
||||
(let [{:keys [unique-name
|
||||
forgejo-host
|
||||
repo-user
|
||||
forgejo-repo
|
||||
branchname]} config
|
||||
name (replace-dots-by-minus unique-name)
|
||||
username "TODO"]
|
||||
name (replace-dots-by-minus unique-name)]
|
||||
(->
|
||||
(yaml/load-as-edn "website/build-configmap.yaml")
|
||||
(replace-all-matching-prefixes "NAME" name)
|
||||
|
@ -131,20 +129,20 @@
|
|||
(generate-gitrepourl
|
||||
forgejo-host
|
||||
forgejo-repo
|
||||
username
|
||||
repo-user
|
||||
branchname)))
|
||||
(cm/replace-all-matching-values-by-new-value "COMMITURL" (b64/encode
|
||||
(generate-gitcommiturl
|
||||
forgejo-host
|
||||
forgejo-repo
|
||||
username))))))
|
||||
|
||||
repo-user))))))
|
||||
; TODO: remove config
|
||||
(defn-spec generate-build-secret pred/map-or-seq?
|
||||
[config websiteconfig?
|
||||
auth websiteauth?]
|
||||
(let [{:keys [unique-name]} config
|
||||
{:keys [authtoken
|
||||
username]} auth
|
||||
{:keys [unique-name
|
||||
authtoken]} auth
|
||||
name (replace-dots-by-minus unique-name)]
|
||||
(->
|
||||
(yaml/load-as-edn "website/build-secret.yaml")
|
||||
|
|
|
@ -28,14 +28,16 @@
|
|||
"{ :websiteconfigs
|
||||
[{:unique-name \"test.io\",
|
||||
:fqdns [\"test.de\" \"www.test.de\"],
|
||||
:gitea-host \"githost.de\",
|
||||
:gitea-repo \"repo\",
|
||||
:forgejo-host \"githost.de\",
|
||||
:repo-user \"someuser\",
|
||||
:forgejo-repo \"repo\",
|
||||
:branchname \"main\",
|
||||
:sha256sum-output \"123456789ab123cd345de script-file-name.sh\"}
|
||||
{:unique-name \"example.io \",
|
||||
:fqdns [\"example.org\" \"www.example.org\"],
|
||||
:gitea-host \"githost.org\",
|
||||
:gitea-repo \"repo\",
|
||||
:forgejo-host \"githost.org\",
|
||||
:repo-user \"someuser\",
|
||||
:forgejo-repo \"repo\",
|
||||
:branchname \"main\",
|
||||
:build-cpu-request \"1500m\",
|
||||
:build-cpu-limit \"3000m\",
|
||||
|
@ -51,10 +53,8 @@
|
|||
:grafana-cloud-password \"your-cloud-password\"}
|
||||
:websiteauths
|
||||
[{:unique-name \"test.io\",
|
||||
:username \"someuser\",
|
||||
:authtoken \"abedjgbasdodj\"}
|
||||
{:unique-name \"example.io\",
|
||||
:username \"someuser\",
|
||||
:authtoken \"abedjgbasdodj\"}]}"
|
||||
"7"))
|
||||
[(br/generate-br)]
|
||||
|
|
|
@ -30,11 +30,13 @@
|
|||
[{:unique-name "example.io"
|
||||
:fqdns ["example.org", "www.example.com"]
|
||||
:forgejo-host "finegitehost.net"
|
||||
:repo-user "someuser"
|
||||
:forgejo-repo "repo"
|
||||
:branchname "main"}
|
||||
{:unique-name "test.io"
|
||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"]
|
||||
:forgejo-host "gitlab.de"
|
||||
:repo-user "someuser"
|
||||
:forgejo-repo "repo"
|
||||
:branchname "main"}]})
|
||||
|
||||
|
@ -43,42 +45,40 @@
|
|||
[{:unique-name "test.io"
|
||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"]
|
||||
:forgejo-host "gitlab.de"
|
||||
:repo-user "someuser"
|
||||
:forgejo-repo "repo"
|
||||
:branchname "main"}
|
||||
{:unique-name "example.io"
|
||||
:fqdns ["example.org", "www.example.com"]
|
||||
:forgejo-host "finegitehost.net"
|
||||
:repo-user "someuser"
|
||||
:forgejo-repo "repo"
|
||||
:branchname "main"}]})
|
||||
|
||||
(def auth1
|
||||
{:websiteauths
|
||||
[{:unique-name "example.io"
|
||||
:username "someuser"
|
||||
:authtoken "abedjgbasdodj"}
|
||||
{:unique-name "test.io"
|
||||
:username "someuser"
|
||||
:authtoken "abedjgbasdodj"}]})
|
||||
|
||||
(def auth2
|
||||
{:websiteauths
|
||||
[{:unique-name "test.io"
|
||||
:username "someuser"
|
||||
:authtoken "abedjgbasdodj"}
|
||||
{:unique-name "example.io"
|
||||
:username "someuser"
|
||||
:authtoken "abedjgbasdodj"}]})
|
||||
|
||||
(def flattened-and-reduced-config
|
||||
{:unique-name "example.io",
|
||||
:fqdns ["example.org" "www.example.com"],
|
||||
:forgejo-host "finegitehost.net",
|
||||
:repo-user "someuser",
|
||||
:forgejo-repo "repo",
|
||||
:branchname "main"})
|
||||
|
||||
(def flattened-and-reduced-auth
|
||||
{:unique-name "example.io",
|
||||
:username "someuser",
|
||||
:authtoken "abedjgbasdodj"})
|
||||
|
||||
(deftest sorts-config
|
||||
|
@ -87,11 +87,13 @@
|
|||
[{:unique-name "example.io",
|
||||
:fqdns ["example.org" "www.example.com"],
|
||||
:forgejo-host "finegitehost.net",
|
||||
:repo-user "someuser",
|
||||
:forgejo-repo "repo",
|
||||
:branchname "main"},
|
||||
{:unique-name "test.io",
|
||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
||||
:forgejo-host "gitlab.de",
|
||||
:repo-user "someuser",
|
||||
:forgejo-repo "repo",
|
||||
:branchname "main",
|
||||
:sha256sum-output "123456789ab123cd345de script-file-name.sh"}],
|
||||
|
@ -102,12 +104,14 @@
|
|||
[{:unique-name "test.io",
|
||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
||||
:forgejo-host "gitlab.de",
|
||||
:repo-user "someuser",
|
||||
:forgejo-repo "repo",
|
||||
:branchname "main",
|
||||
:sha256sum-output "123456789ab123cd345de script-file-name.sh"}
|
||||
{:unique-name "example.io",
|
||||
:fqdns ["example.org" "www.example.com"],
|
||||
:forgejo-host "finegitehost.net",
|
||||
:repo-user "someuser",
|
||||
:forgejo-repo "repo",
|
||||
:branchname "main"}],
|
||||
:mon-cfg {:grafana-cloud-url "url-for-your-prom-remote-write-endpoint", :cluster-name "jitsi", :cluster-stage "test"}}))))
|
||||
|
@ -158,13 +162,14 @@
|
|||
:path "/",
|
||||
:backend {:service {:name "test-io", :port {:number 80}}}}]}}]
|
||||
(get-in
|
||||
(cut/generate-ingress {:forgejo-host "gitlab.de",
|
||||
(cut/generate-ingress {:unique-name "test.io",
|
||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
||||
:forgejo-host "gitlab.de",
|
||||
:repo-user "someuser",
|
||||
:forgejo-repo "repo",
|
||||
:sha256sum-output "123456789ab123cd345de script-file-name.sh",
|
||||
:issuer "staging",
|
||||
:branchname "main",
|
||||
:unique-name "test.io"
|
||||
:build-cpu-request "500m"
|
||||
:build-cpu-limit "1700m"
|
||||
:build-memory-request "256Mi"
|
||||
|
@ -174,13 +179,14 @@
|
|||
[2 :spec :rules])))
|
||||
(is (= "test-io"
|
||||
(get-in
|
||||
(cut/generate-ingress {:forgejo-host "gitlab.de",
|
||||
(cut/generate-ingress {:unique-name "test.io",
|
||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
||||
:forgejo-host "gitlab.de",
|
||||
:repo-user "someuser",
|
||||
:forgejo-repo "repo",
|
||||
:sha256sum-output "123456789ab123cd345de script-file-name.sh",
|
||||
:issuer "staging",
|
||||
:branchname "main",
|
||||
:unique-name "test.io"
|
||||
:build-cpu-request "500m"
|
||||
:build-cpu-limit "1700m"
|
||||
:build-memory-request "256Mi"
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
:redirects [["/products.html", "/offer.html"]
|
||||
["/one-more", "/redirect"]]
|
||||
:forgejo-host "gitea.evilorg",
|
||||
:repo-user "someuser",
|
||||
:forgejo-repo "none",
|
||||
:branchname "mablain",
|
||||
:fqdns ["test.de" "www.test.de" "test-it.de" "www.test-it.de"]}
|
||||
|
@ -45,6 +46,7 @@
|
|||
:unique-name "test.io",
|
||||
:redirects []
|
||||
:forgejo-host "gitea.evilorg",
|
||||
:repo-user "someuser",
|
||||
:forgejo-repo "none",
|
||||
:branchname "mablain",
|
||||
:fqdns ["test.de" "www.test.de" "test-it.de" "www.test-it.de"]}
|
||||
|
@ -54,6 +56,7 @@
|
|||
(deftest should-generate-resource-requests
|
||||
(is (= {:requests {:cpu "1500m", :memory "512Mi"}, :limits {:cpu "3000m", :memory "1024Mi"}}
|
||||
(-> (cut/generate-nginx-deployment {:forgejo-host "gitlab.de",
|
||||
:repo-user "someuser",
|
||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
||||
:forgejo-repo "repo",
|
||||
:issuer "staging",
|
||||
|
@ -68,6 +71,7 @@
|
|||
:spec :template :spec :initContainers first :resources)))
|
||||
(is (= "test-io"
|
||||
(-> (cut/generate-nginx-deployment {:forgejo-host "gitlab.de",
|
||||
:repo-user "someuser",
|
||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
||||
:forgejo-repo "repo",
|
||||
:issuer "staging",
|
||||
|
@ -92,6 +96,7 @@
|
|||
:redirects [["/products.html", "/offer.html"]
|
||||
["/one-more", "/redirect"]]
|
||||
:forgejo-host "gitea.evilorg",
|
||||
:repo-user "someuser",
|
||||
:forgejo-repo "none",
|
||||
:branchname "mablain",
|
||||
:fqdns ["test.de" "www.test.de" "test-it.de" "www.test-it.de"]})))
|
||||
|
@ -107,6 +112,7 @@
|
|||
:redirects [["/products.html", "/offer.html"]
|
||||
["/one-more", "/redirect"]]
|
||||
:forgejo-host "gitea.evilorg",
|
||||
:repo-user "someuser",
|
||||
:forgejo-repo "none",
|
||||
:branchname "mablain",
|
||||
:fqdns ["test.de" "www.test.de" "test-it.de" "www.test-it.de"]})))
|
||||
|
@ -121,6 +127,7 @@
|
|||
:unique-name "test.io",
|
||||
:redirects [],
|
||||
:forgejo-host "gitea.evilorg",
|
||||
:repo-user "someuser",
|
||||
:forgejo-repo "none",
|
||||
:branchname "mablain",
|
||||
:fqdns ["test.de" "www.test.de" "test-it.de" "www.test-it.de"]})))
|
||||
|
@ -139,6 +146,7 @@
|
|||
:unique-name "test.io",
|
||||
:redirects [],
|
||||
:forgejo-host "gitea.evilorg",
|
||||
:repo-user "someuser",
|
||||
:forgejo-repo "none",
|
||||
:branchname "mablain",
|
||||
:fqdns ["test.de" "www.test.de" "test-it.de" "www.test-it.de"]})
|
||||
|
@ -162,6 +170,7 @@
|
|||
:unique-name "test.io",
|
||||
:redirects [],
|
||||
:forgejo-host "gitea.evilorg",
|
||||
:repo-user "someuser",
|
||||
:forgejo-repo "none",
|
||||
:branchname "mablain",
|
||||
:fqdns ["test.de" "www.test.de" "test-it.de" "www.test-it.de"]}))))
|
||||
|
@ -204,6 +213,7 @@
|
|||
:build-memory-limit "512Mi"
|
||||
:volume-size "3"
|
||||
:forgejo-host "gitlab.de",
|
||||
:repo-user "someuser",
|
||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
||||
:forgejo-repo "repo",
|
||||
:branchname "main",
|
||||
|
@ -225,14 +235,14 @@
|
|||
: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",
|
||||
:authtoken "abedjgbasdodj",
|
||||
:username "someuser"}))))
|
||||
:authtoken "abedjgbasdodj"}))))
|
||||
|
||||
(deftest should-generate-content-pvc
|
||||
(is (= {:apiVersion "v1",
|
||||
|
@ -254,6 +264,7 @@
|
|||
:unique-name "test.io",
|
||||
:redirects [],
|
||||
:forgejo-host "gitea.evilorg",
|
||||
:repo-user "someuser",
|
||||
:forgejo-repo "none",
|
||||
:branchname "mablain",
|
||||
:fqdns ["test.de" "www.test.de" "test-it.de" "www.test-it.de"]}))))
|
||||
|
@ -278,6 +289,7 @@
|
|||
:unique-name "test.io",
|
||||
:redirects [],
|
||||
:forgejo-host "gitea.evilorg",
|
||||
:repo-user "someuser",
|
||||
:forgejo-repo "none",
|
||||
:branchname "mablain",
|
||||
:fqdns ["test.de" "www.test.de" "test-it.de" "www.test-it.de"]}))))
|
|
@ -1,9 +1,7 @@
|
|||
websiteauths:
|
||||
- unique-name: "test.io"
|
||||
username: "someuser"
|
||||
authtoken: "abedjgbasdodj"
|
||||
- unique-name: "example.io"
|
||||
username: "someuser"
|
||||
authtoken: "abedjgbasdodj"
|
||||
mon-auth:
|
||||
grafana-cloud-user: "user"
|
||||
|
|
|
@ -3,6 +3,7 @@ websiteconfigs:
|
|||
- unique-name: "test.io"
|
||||
fqdns: ["test.de", "test.org", "www.test.de", "www.test.org"]
|
||||
forgejo-host: "codeberg.org"
|
||||
repo-user: "someuser"
|
||||
forgejo-repo: "repo"
|
||||
branchname: "main"
|
||||
redirects:
|
||||
|
@ -11,6 +12,7 @@ websiteconfigs:
|
|||
- unique-name: "example.io"
|
||||
fqdns: ["example.org", "www.example.com"]
|
||||
forgejo-host: "fineForgejoHost.net"
|
||||
repo-user: "someotheruser"
|
||||
forgejo-repo: "repo"
|
||||
branchname: "main"
|
||||
mon-cfg:
|
||||
|
|
Loading…
Reference in a new issue