Compare commits
40 commits
Author | SHA1 | Date | |
---|---|---|---|
d1dfeb092f | |||
d171ef0102 | |||
|
9501120d88 | ||
|
2e7de036a5 | ||
a8e1dae976 | |||
89cd45fdd3 | |||
b593ac8b7c | |||
87a18c4010 | |||
84646748f2 | |||
1f8ced4e6d | |||
76882ba196 | |||
a84ef439cb | |||
457b106829 | |||
f78e089639 | |||
86f3bd94fb | |||
b07191d9d5 | |||
3524b2209e | |||
d43cad692a | |||
0cd0225918 | |||
07cea8cfeb | |||
|
a1803e79a6 | ||
|
e1d43cddc5 | ||
|
3944c28562 | ||
|
56a08653e9 | ||
|
889b95f572 | ||
|
9e8af08ec2 | ||
|
26a687c488 | ||
|
d1764c64ed | ||
|
7e146a3463 | ||
|
164f66d4b7 | ||
|
ebca7a3454 | ||
|
548dd14091 | ||
|
f1e41b3333 | ||
|
9e75c22337 | ||
|
e02f4949fc | ||
|
e923c9d5c3 | ||
|
248c33613a | ||
|
600dd1c30a | ||
d496ba28f6 | |||
e69c9e87bd |
21 changed files with 267 additions and 148 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[![Clojars Project](https://img.shields.io/clojars/v/org.domaindrivenarchitecture/c4k-website.svg)](https://clojars.org/org.domaindrivenarchitecture/c4k-website) [![pipeline status](https://gitlab.com/domaindrivenarchitecture/c4k-website/badges/master/pipeline.svg)](https://gitlab.com/domaindrivenarchitecture/c4k-website/-/commits/main)
|
[![Clojars Project](https://img.shields.io/clojars/v/org.domaindrivenarchitecture/c4k-website.svg)](https://clojars.org/org.domaindrivenarchitecture/c4k-website) [![pipeline status](https://gitlab.com/domaindrivenarchitecture/c4k-website/badges/master/pipeline.svg)](https://gitlab.com/domaindrivenarchitecture/c4k-website/-/commits/main)
|
||||||
|
|
||||||
[<img src="https://domaindrivenarchitecture.org/img/delta-chat.svg" width=20 alt="DeltaChat"> chat over e-mail](mailto:buero@meissa-gmbh.de?subject=community-chat) | [<img src="https://meissa-gmbh.de/img/community/Mastodon_Logotype.svg" width=20 alt="team@social.meissa-gmbh.de"> team@social.meissa-gmbh.de](https://social.meissa-gmbh.de/@team) | [Website & Blog](https://domaindrivenarchitecture.org)
|
[<img src="https://domaindrivenarchitecture.org/img/delta-chat.svg" width=20 alt="DeltaChat"> chat over e-mail](mailto:buero@meissa-gmbh.de?subject=community-chat) | [<img src="https://meissa.de/images/parts/contact/mastodon36_hue9b2464f10b18e134322af482b9c915e_5501_filter_14705073121015236177.png" width=20 alt="M"> meissa@social.meissa-gmbh.de](https://social.meissa-gmbh.de/@meissa) | [Blog](https://domaindrivenarchitecture.org) | [Website](https://meissa.de)
|
||||||
|
|
||||||
## Purpose
|
## Purpose
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,12 @@ websiteconfigs:
|
||||||
- unique-name: "test.io"
|
- unique-name: "test.io"
|
||||||
fqdns: ["test.de", "test.org", "www.test.de", "www.test.org"]
|
fqdns: ["test.de", "test.org", "www.test.de", "www.test.org"]
|
||||||
forgejo-host: "codeberg.org"
|
forgejo-host: "codeberg.org"
|
||||||
forgejo-repo: "repo"
|
repo-name: "repo"
|
||||||
branchname: "main"
|
branchname: "main"
|
||||||
- unique-name: "example.io"
|
- unique-name: "example.io"
|
||||||
fqdns: ["example.org", "www.example.com"]
|
fqdns: ["example.org", "www.example.com"]
|
||||||
forgejo-host: "fineForgejoHost.net"
|
forgejo-host: "fineForgejoHost.net"
|
||||||
forgejo-repo: "repo"
|
repo-name: "repo"
|
||||||
branchname: "main"
|
branchname: "main"
|
||||||
mon-cfg:
|
mon-cfg:
|
||||||
grafana-cloud-url: "url-for-your-prom-remote-write-endpoint"
|
grafana-cloud-url: "url-for-your-prom-remote-write-endpoint"
|
||||||
|
|
|
@ -7,7 +7,7 @@ import logging
|
||||||
name = 'c4k-website'
|
name = 'c4k-website'
|
||||||
MODULE = 'build'
|
MODULE = 'build'
|
||||||
PROJECT_ROOT_PATH = '../..'
|
PROJECT_ROOT_PATH = '../..'
|
||||||
version = "2.0.0"
|
version = "2.0.4-dev"
|
||||||
|
|
||||||
|
|
||||||
@init
|
@init
|
||||||
|
|
|
@ -3,9 +3,12 @@ FROM clojure:lein
|
||||||
# Prepare Entrypoint Script
|
# Prepare Entrypoint Script
|
||||||
ADD resources /tmp
|
ADD resources /tmp
|
||||||
|
|
||||||
|
ENV HUGO_VERSION="0.125.5"
|
||||||
|
ENV GO_VERSION="1.19.13"
|
||||||
ENV BUILDDIR="/etc/website"
|
ENV BUILDDIR="/etc/website"
|
||||||
ENV SOURCEDIR="/etc/websitesource"
|
ENV SOURCEDIR="/etc/websitesource"
|
||||||
ENV WEBSITEROOT="/var/www/html/website/"
|
ENV WEBSITEROOT="/var/www/html/website/"
|
||||||
ENV HASHFILEDIR="/var/hashfile.d"
|
ENV HASHFILEDIR="/var/hashfile.d"
|
||||||
|
ENV PATH="${PATH}:/usr/local/go/bin"
|
||||||
|
|
||||||
RUN /tmp/install.sh
|
RUN /tmp/install.sh
|
||||||
|
|
|
@ -20,6 +20,8 @@ if [[ $currentHash == $newHash ]]
|
||||||
echo "Nothing to do"
|
echo "Nothing to do"
|
||||||
else
|
else
|
||||||
echo $currentHash > $HASHFILEDIR/$hashfilename
|
echo $currentHash > $HASHFILEDIR/$hashfilename
|
||||||
|
echo "Generate .netrc file"
|
||||||
|
generate-netrc-file
|
||||||
echo "Downloading website data"
|
echo "Downloading website data"
|
||||||
get-website-data $filename
|
get-website-data $filename
|
||||||
unzip-website-data $filename
|
unzip-website-data $filename
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
function generate-netrc-file() {
|
||||||
|
echo "machine $GITHOST password $AUTHTOKEN" > ~/.netrc
|
||||||
|
}
|
||||||
|
|
||||||
function get-website-data() {
|
function get-website-data() {
|
||||||
curl -H "Authorization: token $AUTHTOKEN" -o $SOURCEDIR/$1 $GITREPOURL
|
curl -H "Authorization: token $AUTHTOKEN" -o $SOURCEDIR/$1 $GITREPOURL
|
||||||
}
|
}
|
||||||
|
@ -17,9 +21,49 @@ function unzip-website-data() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function build-website() {
|
function build-website() {
|
||||||
(cd $BUILDDIR; dir=$(ls); cd $dir; ./generate.sh;)
|
(cd $BUILDDIR; dir=$(ls); cd $dir; bash generate.sh;)
|
||||||
}
|
}
|
||||||
|
|
||||||
function move-website-files-to-target() {
|
function move-website-files-to-target() {
|
||||||
(cd $BUILDDIR; dir=$(ls); cd $dir; rsync -ru --exclude-from "/etc/exclude.pattern" --delete target/html/* $WEBSITEROOT;)
|
(cd $BUILDDIR; dir=$(ls); cd $dir; rsync -ru --exclude-from "/etc/exclude.pattern" --delete target/html/* $WEBSITEROOT;)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function install-hugo-from-deb() {
|
||||||
|
curl -L "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb" -o hugo_extended_${HUGO_VERSION}_linux-amd64.deb
|
||||||
|
curl -L "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_checksums.txt" -o checksums.txt
|
||||||
|
EXPECTED_CHECKSUM="$(sha256sum hugo_extended_${HUGO_VERSION}_linux-amd64.deb)"
|
||||||
|
ACTUAL_CHECKSUM="$(grep hugo_extended_${HUGO_VERSION}_linux-amd64.deb checksums.txt)"
|
||||||
|
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
|
||||||
|
then
|
||||||
|
>&2 echo 'ERROR: Invalid installer checksum'
|
||||||
|
rm hugo.deb
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Installing hugo"
|
||||||
|
echo
|
||||||
|
dpkg -i hugo_extended_${HUGO_VERSION}_linux-amd64.deb
|
||||||
|
|
||||||
|
echo "Clean up"
|
||||||
|
rm hugo_extended_${HUGO_VERSION}_linux-amd64.deb
|
||||||
|
rm checksums.txt
|
||||||
|
}
|
||||||
|
|
||||||
|
function install-go-from-tar() {
|
||||||
|
curl -L "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" -o go_linux-amd64.tar.gz
|
||||||
|
EXPECTED_CHECKSUM="4643d4c29c55f53fa0349367d7f1bb5ca554ea6ef528c146825b0f8464e2e668 go_linux-amd64.tar.gz"
|
||||||
|
ACTUAL_CHECKSUM="$(sha256sum go_linux-amd64.tar.gz)"
|
||||||
|
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
|
||||||
|
then
|
||||||
|
>&2 echo 'ERROR: Invalid installer checksum'
|
||||||
|
rm go_linux-amd64.tar.gz
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Installing go"
|
||||||
|
echo
|
||||||
|
tar -C /usr/local -xzf go_linux-amd64.tar.gz
|
||||||
|
|
||||||
|
echo "Clean up"
|
||||||
|
rm go_linux-amd64.tar.gz
|
||||||
|
}
|
|
@ -6,7 +6,9 @@ function main()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
upgradeSystem
|
upgradeSystem
|
||||||
apt-get install -qqy unzip rsync jq imagemagick curl
|
apt-get install -qqy unzip rsync jq imagemagick curl git
|
||||||
|
install-hugo-from-deb
|
||||||
|
install-go-from-tar
|
||||||
|
|
||||||
install -d /etc/lein/
|
install -d /etc/lein/
|
||||||
install -m 0700 /tmp/entrypoint.sh /
|
install -m 0700 /tmp/entrypoint.sh /
|
||||||
|
@ -22,4 +24,5 @@ function main()
|
||||||
}
|
}
|
||||||
|
|
||||||
source /tmp/install_functions_debian.sh
|
source /tmp/install_functions_debian.sh
|
||||||
|
source /tmp/functions.sh
|
||||||
DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes main
|
DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes main
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "c4k-website",
|
"name": "c4k-website",
|
||||||
"description": "Generate c4k yaml for a website deployment.",
|
"description": "Generate c4k yaml for a website deployment.",
|
||||||
"author": "meissa GmbH",
|
"author": "meissa GmbH",
|
||||||
"version": "2.0.0",
|
"version": "2.0.4-SNAPSHOT",
|
||||||
"homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-website#readme",
|
"homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-website#readme",
|
||||||
"repository": "https://www.npmjs.com/package/c4k-website",
|
"repository": "https://www.npmjs.com/package/c4k-website",
|
||||||
"license": "APACHE2",
|
"license": "APACHE2",
|
||||||
|
|
12
project.clj
12
project.clj
|
@ -1,11 +1,11 @@
|
||||||
(defproject org.domaindrivenarchitecture/c4k-website "2.0.0"
|
(defproject org.domaindrivenarchitecture/c4k-website "2.0.4-SNAPSHOT"
|
||||||
:description "website c4k-installation package"
|
:description "website c4k-installation package"
|
||||||
:url "https://domaindrivenarchitecture.org"
|
:url "https://domaindrivenarchitecture.org"
|
||||||
:license {:name "Apache License, Version 2.0"
|
:license {:name "Apache License, Version 2.0"
|
||||||
:url "https://www.apache.org/licenses/LICENSE-2.0.html"}
|
:url "https://www.apache.org/licenses/LICENSE-2.0.html"}
|
||||||
:dependencies [[org.clojure/clojure "1.11.1"]
|
:dependencies [[org.clojure/clojure "1.11.3"]
|
||||||
[org.clojure/tools.reader "1.4.0"]
|
[org.clojure/tools.reader "1.4.2"]
|
||||||
[org.domaindrivenarchitecture/c4k-common-clj "6.2.2"]
|
[org.domaindrivenarchitecture/c4k-common-clj "6.2.3"]
|
||||||
[hickory "0.7.1" :exclusions [viebel/codox-klipse-theme]]]
|
[hickory "0.7.1" :exclusions [viebel/codox-klipse-theme]]]
|
||||||
:target-path "target/%s/"
|
:target-path "target/%s/"
|
||||||
:source-paths ["src/main/cljc"
|
:source-paths ["src/main/cljc"
|
||||||
|
@ -23,9 +23,9 @@
|
||||||
:main dda.c4k-website.uberjar
|
:main dda.c4k-website.uberjar
|
||||||
:uberjar-name "c4k-website-standalone.jar"
|
:uberjar-name "c4k-website-standalone.jar"
|
||||||
:dependencies [[org.clojure/tools.cli "1.1.230"]
|
:dependencies [[org.clojure/tools.cli "1.1.230"]
|
||||||
[ch.qos.logback/logback-classic "1.5.1"
|
[ch.qos.logback/logback-classic "1.5.6"
|
||||||
:exclusions [com.sun.mail/javax.mail]]
|
:exclusions [com.sun.mail/javax.mail]]
|
||||||
[org.slf4j/jcl-over-slf4j "2.0.12"]
|
[org.slf4j/jcl-over-slf4j "2.0.13"]
|
||||||
[com.github.clj-easy/graal-build-time "1.0.5"]]}}
|
[com.github.clj-easy/graal-build-time "1.0.5"]]}}
|
||||||
:release-tasks [["test"]
|
:release-tasks [["test"]
|
||||||
["vcs" "assert-committed"]
|
["vcs" "assert-committed"]
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"src/test/cljc"
|
"src/test/cljc"
|
||||||
"src/test/cljs"
|
"src/test/cljs"
|
||||||
"src/test/resources"]
|
"src/test/resources"]
|
||||||
:dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "6.2.2"]
|
:dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "6.2.3"]
|
||||||
[hickory "0.7.1"]]
|
[hickory "0.7.1"]]
|
||||||
:builds {:frontend {:target :browser
|
:builds {:frontend {:target :browser
|
||||||
:modules {:main {:init-fn dda.c4k-website.browser/init}}
|
:modules {:main {:init-fn dda.c4k-website.browser/init}}
|
||||||
|
|
|
@ -16,36 +16,46 @@
|
||||||
(s/def ::unique-name ::web/unique-name)
|
(s/def ::unique-name ::web/unique-name)
|
||||||
(s/def ::issuer ::web/issuer)
|
(s/def ::issuer ::web/issuer)
|
||||||
(s/def ::volume-size ::web/volume-size)
|
(s/def ::volume-size ::web/volume-size)
|
||||||
|
(s/def ::average-rate ::ing/average-rate)
|
||||||
|
(s/def ::burst-rate ::ing/burst-rate)
|
||||||
|
|
||||||
(s/def ::authtoken ::web/authtoken)
|
(s/def ::authtoken ::web/authtoken)
|
||||||
(s/def ::fqdns ::web/fqdns)
|
(s/def ::fqdns ::web/fqdns)
|
||||||
(s/def ::forgejo-host ::web/forgejo-host)
|
(s/def ::forgejo-host ::web/forgejo-host)
|
||||||
(s/def ::forgejo-repo ::web/forgejo-repo)
|
(s/def ::repo-owner ::web/repo-owner)
|
||||||
|
(s/def ::repo-name ::web/repo-name)
|
||||||
(s/def ::branchname ::web/branchname)
|
(s/def ::branchname ::web/branchname)
|
||||||
(s/def ::username ::web/username)
|
|
||||||
(s/def ::build-cpu-request ::web/build-cpu-request)
|
(s/def ::build-cpu-request ::web/build-cpu-request)
|
||||||
(s/def ::build-memory-request ::web/build-memory-request)
|
(s/def ::build-memory-request ::web/build-memory-request)
|
||||||
(s/def ::build-cpu-limit ::web/build-cpu-limit)
|
(s/def ::build-cpu-limit ::web/build-cpu-limit)
|
||||||
(s/def ::build-memory-limit ::web/build-memory-limit)
|
(s/def ::build-memory-limit ::web/build-memory-limit)
|
||||||
|
(s/def ::redirects ::web/redirects)
|
||||||
|
|
||||||
(def websiteconfig? (s/keys :req-un [::unique-name
|
(def websiteconfig? (s/keys :req-un [::unique-name
|
||||||
::fqdns
|
::fqdns
|
||||||
::forgejo-host
|
::forgejo-host
|
||||||
::forgejo-repo
|
::repo-owner
|
||||||
|
::repo-name
|
||||||
::branchname]
|
::branchname]
|
||||||
:opt-un [::issuer
|
:opt-un [::issuer
|
||||||
::volume-size
|
::volume-size
|
||||||
::build-cpu-request
|
::build-cpu-request
|
||||||
::build-cpu-limit
|
::build-cpu-limit
|
||||||
::build-memory-request
|
::build-memory-request
|
||||||
::build-memory-limit]))
|
::build-memory-limit
|
||||||
(def websiteauth? (s/keys :req-un [::unique-name ::username ::authtoken]))
|
::redirects]))
|
||||||
|
(def websiteauth? web/websiteauth?)
|
||||||
|
(def websiteauths? (s/keys :req-un [::websiteauths]))
|
||||||
|
|
||||||
(s/def ::websiteconfigs (s/coll-of websiteconfig?))
|
(s/def ::websiteconfigs (s/coll-of websiteconfig?))
|
||||||
(s/def ::websiteauths (s/coll-of websiteauth?))
|
(s/def ::websiteauths (s/coll-of websiteauth?))
|
||||||
|
|
||||||
(def config? (s/keys :req-un [::websiteconfigs]
|
(def config? (s/keys :req-un [::websiteconfigs]
|
||||||
:opt-un [::issuer
|
:opt-un [::issuer
|
||||||
::volume-size
|
::volume-size
|
||||||
::mon-cfg]))
|
::mon-cfg
|
||||||
|
::average-rate
|
||||||
|
::burst-rate]))
|
||||||
|
|
||||||
(def auth? (s/keys :req-un [::websiteauths]
|
(def auth? (s/keys :req-un [::websiteauths]
|
||||||
:opt-un [::mon-auth]))
|
:opt-un [::mon-auth]))
|
||||||
|
@ -58,7 +68,9 @@
|
||||||
:build-memory-request "256Mi"
|
:build-memory-request "256Mi"
|
||||||
:build-memory-limit "512Mi"
|
:build-memory-limit "512Mi"
|
||||||
:volume-size "3"
|
:volume-size "3"
|
||||||
:redirects []})
|
:redirects []
|
||||||
|
:average-rate 20
|
||||||
|
:burst-rate 40})
|
||||||
|
|
||||||
(defn-spec sort-config map?
|
(defn-spec sort-config map?
|
||||||
[unsorted-config config?]
|
[unsorted-config config?]
|
||||||
|
@ -80,7 +92,11 @@
|
||||||
(when (contains? config :issuer)
|
(when (contains? config :issuer)
|
||||||
{:issuer (config :issuer)})
|
{:issuer (config :issuer)})
|
||||||
(when (contains? config :volume-size)
|
(when (contains? config :volume-size)
|
||||||
{:volume-size (config :volume-size)}))))
|
{:volume-size (config :volume-size)})
|
||||||
|
(when (contains? config :average-rate)
|
||||||
|
{:average-rate (config :average-rate)})
|
||||||
|
(when (contains? config :burst-rate)
|
||||||
|
{:burst-rate (config :burst-rate)}))))
|
||||||
|
|
||||||
(defn-spec flatten-and-reduce-auth map?
|
(defn-spec flatten-and-reduce-auth map?
|
||||||
[auth auth?]
|
[auth auth?]
|
||||||
|
@ -99,35 +115,35 @@
|
||||||
(defn-spec generate seq?
|
(defn-spec generate seq?
|
||||||
[config config?
|
[config config?
|
||||||
auth auth?]
|
auth auth?]
|
||||||
(loop [config (sort-config config)
|
(loop [sorted-config (sort-config config)
|
||||||
sorted-auth (sort-auth auth)
|
sorted-auth (sort-auth auth)
|
||||||
result []]
|
result []]
|
||||||
|
|
||||||
(if (and (empty? (config :websiteconfigs)) (empty? (sorted-auth :websiteauths)))
|
(if (and (empty? (sorted-config :websiteconfigs)) (empty? (sorted-auth :websiteauths)))
|
||||||
result
|
result
|
||||||
(recur (->
|
(recur (->
|
||||||
config
|
sorted-config
|
||||||
(assoc-in [:websiteconfigs] (rest (config :websiteconfigs))))
|
(assoc-in [:websiteconfigs] (rest (sorted-config :websiteconfigs))))
|
||||||
(->
|
(->
|
||||||
auth
|
sorted-auth
|
||||||
(assoc-in [:websiteauths] (rest (sorted-auth :websiteauths))))
|
(assoc-in [:websiteauths] (rest (sorted-auth :websiteauths))))
|
||||||
(let [final-config
|
(let [curr-flat-websiteconfig
|
||||||
(merge
|
(merge
|
||||||
website-config-defaults
|
website-config-defaults
|
||||||
(flatten-and-reduce-config config))
|
(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
|
(cm/concat-vec
|
||||||
result
|
result
|
||||||
(ns/generate (merge {:namespace name} final-config))
|
(ns/generate (merge {:namespace name} curr-flat-websiteconfig))
|
||||||
[(web/generate-nginx-deployment final-config)
|
[(web/generate-nginx-deployment curr-flat-websiteconfig)
|
||||||
(web/generate-nginx-configmap final-config)
|
(web/generate-nginx-configmap curr-flat-websiteconfig)
|
||||||
(web/generate-nginx-service final-config)
|
(web/generate-nginx-service curr-flat-websiteconfig)
|
||||||
(web/generate-content-pvc final-config)
|
(web/generate-content-pvc curr-flat-websiteconfig)
|
||||||
(web/generate-hash-state-pvc final-config)
|
(web/generate-hash-state-pvc curr-flat-websiteconfig)
|
||||||
(web/generate-build-cron final-config)
|
(web/generate-build-cron curr-flat-websiteconfig)
|
||||||
(web/generate-build-secret final-config
|
(web/generate-build-configmap curr-flat-websiteconfig)
|
||||||
(flatten-and-reduce-auth auth))]
|
(web/generate-build-secret (flatten-and-reduce-auth sorted-auth))]
|
||||||
(generate-ingress final-config)))))))
|
(generate-ingress curr-flat-websiteconfig)))))))
|
||||||
|
|
||||||
(defn-spec k8s-objects cp/map-or-seq?
|
(defn-spec k8s-objects cp/map-or-seq?
|
||||||
[config config?
|
[config config?
|
||||||
|
|
|
@ -20,9 +20,9 @@
|
||||||
(s/def ::authtoken pred/bash-env-string?)
|
(s/def ::authtoken pred/bash-env-string?)
|
||||||
(s/def ::fqdns (s/coll-of pred/fqdn-string?))
|
(s/def ::fqdns (s/coll-of pred/fqdn-string?))
|
||||||
(s/def ::forgejo-host pred/fqdn-string?)
|
(s/def ::forgejo-host pred/fqdn-string?)
|
||||||
(s/def ::forgejo-repo string?)
|
(s/def ::repo-name string?)
|
||||||
(s/def ::branchname string?)
|
(s/def ::branchname string?)
|
||||||
(s/def ::username string?)
|
(s/def ::repo-owner string?)
|
||||||
(s/def ::build-cpu-request string?)
|
(s/def ::build-cpu-request string?)
|
||||||
(s/def ::build-memory-request string?)
|
(s/def ::build-memory-request string?)
|
||||||
(s/def ::build-cpu-limit string?)
|
(s/def ::build-cpu-limit string?)
|
||||||
|
@ -30,29 +30,21 @@
|
||||||
(s/def ::redirect (s/tuple string? string?))
|
(s/def ::redirect (s/tuple string? string?))
|
||||||
(s/def ::redirects (s/coll-of ::redirect))
|
(s/def ::redirects (s/coll-of ::redirect))
|
||||||
|
|
||||||
|
|
||||||
(def websiteconfig? (s/keys :req-un [::unique-name
|
(def websiteconfig? (s/keys :req-un [::unique-name
|
||||||
::fqdns
|
::fqdns
|
||||||
::forgejo-host
|
::forgejo-host
|
||||||
::forgejo-repo
|
::repo-owner
|
||||||
|
::repo-name
|
||||||
::branchname
|
::branchname
|
||||||
::issuer
|
|
||||||
::volume-size
|
|
||||||
::build-cpu-request
|
::build-cpu-request
|
||||||
::build-cpu-limit
|
::build-cpu-limit
|
||||||
::build-memory-request
|
::build-memory-request
|
||||||
::build-memory-limit
|
::build-memory-limit
|
||||||
|
::issuer
|
||||||
|
::volume-size
|
||||||
::redirects]))
|
::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?))
|
|
||||||
|
|
||||||
(s/def ::websiteauths (s/coll-of websiteauth?))
|
|
||||||
|
|
||||||
(def websiteconfigs? (s/keys :req-un [::websiteconfigs]))
|
|
||||||
|
|
||||||
(def auth? (s/keys :req-un [::websiteauths]))
|
|
||||||
|
|
||||||
(defn-spec replace-dots-by-minus string?
|
(defn-spec replace-dots-by-minus string?
|
||||||
[fqdn pred/fqdn-string?]
|
[fqdn pred/fqdn-string?]
|
||||||
|
@ -61,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?
|
||||||
|
@ -94,7 +86,6 @@
|
||||||
#(str "rewrite ^" (first %1) "\\$ " (second %1) " permanent;")
|
#(str "rewrite ^" (first %1) "\\$ " (second %1) " permanent;")
|
||||||
redirects))))
|
redirects))))
|
||||||
|
|
||||||
|
|
||||||
(defn-spec generate-nginx-configmap map?
|
(defn-spec generate-nginx-configmap map?
|
||||||
[config websiteconfig?]
|
[config websiteconfig?]
|
||||||
(let [{:keys [fqdns unique-name]} config
|
(let [{:keys [fqdns unique-name]} config
|
||||||
|
@ -113,32 +104,37 @@
|
||||||
#"REDIRECTS"
|
#"REDIRECTS"
|
||||||
(generate-redirects config 2)))))))
|
(generate-redirects config 2)))))))
|
||||||
|
|
||||||
|
(defn-spec generate-build-configmap pred/map-or-seq?
|
||||||
(defn-spec generate-build-secret pred/map-or-seq?
|
[config websiteconfig?]
|
||||||
[config websiteconfig?
|
|
||||||
auth websiteauth?]
|
|
||||||
(let [{:keys [unique-name
|
(let [{:keys [unique-name
|
||||||
forgejo-host
|
forgejo-host
|
||||||
forgejo-repo
|
repo-owner
|
||||||
|
repo-name
|
||||||
branchname]} config
|
branchname]} config
|
||||||
{:keys [authtoken
|
name (replace-dots-by-minus unique-name)]
|
||||||
username]} auth
|
(->
|
||||||
|
(yaml/load-as-edn "website/build-configmap.yaml")
|
||||||
|
(replace-all-matching-prefixes "NAME" name)
|
||||||
|
(cm/replace-all-matching-values-by-new-value "GITHOST" forgejo-host)
|
||||||
|
(cm/replace-all-matching-values-by-new-value "REPOURL" (generate-gitrepourl
|
||||||
|
forgejo-host
|
||||||
|
repo-owner
|
||||||
|
repo-name
|
||||||
|
branchname))
|
||||||
|
(cm/replace-all-matching-values-by-new-value "COMMITURL" (generate-gitcommiturl
|
||||||
|
forgejo-host
|
||||||
|
repo-owner
|
||||||
|
repo-name)))))
|
||||||
|
|
||||||
|
(defn-spec generate-build-secret pred/map-or-seq?
|
||||||
|
[auth websiteauth?]
|
||||||
|
(let [{:keys [unique-name
|
||||||
|
authtoken]} auth
|
||||||
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-prefixes "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
|
|
||||||
(generate-gitrepourl
|
|
||||||
forgejo-host
|
|
||||||
forgejo-repo
|
|
||||||
username
|
|
||||||
branchname)))
|
|
||||||
(cm/replace-all-matching-values-by-new-value "COMMITURL" (b64/encode
|
|
||||||
(generate-gitcommiturl
|
|
||||||
forgejo-host
|
|
||||||
forgejo-repo
|
|
||||||
username))))))
|
|
||||||
|
|
||||||
|
|
||||||
(defn-spec generate-content-pvc map?
|
(defn-spec generate-content-pvc map?
|
||||||
|
|
|
@ -28,14 +28,16 @@
|
||||||
"{ :websiteconfigs
|
"{ :websiteconfigs
|
||||||
[{:unique-name \"test.io\",
|
[{:unique-name \"test.io\",
|
||||||
:fqdns [\"test.de\" \"www.test.de\"],
|
:fqdns [\"test.de\" \"www.test.de\"],
|
||||||
:gitea-host \"githost.de\",
|
:forgejo-host \"githost.de\",
|
||||||
:gitea-repo \"repo\",
|
:repo-owner \"someuser\",
|
||||||
|
:repo-name \"repo\",
|
||||||
:branchname \"main\",
|
:branchname \"main\",
|
||||||
:sha256sum-output \"123456789ab123cd345de script-file-name.sh\"}
|
:sha256sum-output \"123456789ab123cd345de script-file-name.sh\"}
|
||||||
{:unique-name \"example.io \",
|
{:unique-name \"example.io \",
|
||||||
:fqdns [\"example.org\" \"www.example.org\"],
|
:fqdns [\"example.org\" \"www.example.org\"],
|
||||||
:gitea-host \"githost.org\",
|
:forgejo-host \"githost.org\",
|
||||||
:gitea-repo \"repo\",
|
:repo-owner \"someuser\",
|
||||||
|
:repo-name \"repo\",
|
||||||
:branchname \"main\",
|
:branchname \"main\",
|
||||||
:build-cpu-request \"1500m\",
|
:build-cpu-request \"1500m\",
|
||||||
:build-cpu-limit \"3000m\",
|
:build-cpu-limit \"3000m\",
|
||||||
|
@ -51,10 +53,8 @@
|
||||||
:grafana-cloud-password \"your-cloud-password\"}
|
:grafana-cloud-password \"your-cloud-password\"}
|
||||||
:websiteauths
|
:websiteauths
|
||||||
[{:unique-name \"test.io\",
|
[{:unique-name \"test.io\",
|
||||||
:username \"someuser\",
|
|
||||||
:authtoken \"abedjgbasdodj\"}
|
:authtoken \"abedjgbasdodj\"}
|
||||||
{:unique-name \"example.io\",
|
{:unique-name \"example.io\",
|
||||||
:username \"someuser\",
|
|
||||||
:authtoken \"abedjgbasdodj\"}]}"
|
:authtoken \"abedjgbasdodj\"}]}"
|
||||||
"7"))
|
"7"))
|
||||||
[(br/generate-br)]
|
[(br/generate-br)]
|
||||||
|
@ -84,12 +84,12 @@
|
||||||
:grafana-cloud-url mon-cloud-url}}))))
|
:grafana-cloud-url mon-cloud-url}}))))
|
||||||
|
|
||||||
(defn validate-all! []
|
(defn validate-all! []
|
||||||
(br/validate! "websiteconfigs" website/websiteconfigs? :deserializer edn/read-string)
|
(br/validate! "websiteconfigs" core/websiteconfigs? :deserializer edn/read-string)
|
||||||
(br/validate! "issuer" ::website/issuer :optional true)
|
(br/validate! "issuer" ::core/issuer :optional true)
|
||||||
(br/validate! "mon-cluster-name" ::mon/cluster-name :optional true)
|
(br/validate! "mon-cluster-name" ::mon/cluster-name :optional true)
|
||||||
(br/validate! "mon-cluster-stage" ::mon/cluster-stage :optional true)
|
(br/validate! "mon-cluster-stage" ::mon/cluster-stage :optional true)
|
||||||
(br/validate! "mon-cloud-url" ::mon/grafana-cloud-url :optional true)
|
(br/validate! "mon-cloud-url" ::mon/grafana-cloud-url :optional true)
|
||||||
(br/validate! "auth" website/auth? :deserializer edn/read-string)
|
(br/validate! "auth" core/websiteauths? :deserializer edn/read-string)
|
||||||
(br/set-form-validated!))
|
(br/set-form-validated!))
|
||||||
|
|
||||||
(defn add-validate-listener [name]
|
(defn add-validate-listener [name]
|
||||||
|
|
11
src/main/resources/website/build-configmap.yaml
Normal file
11
src/main/resources/website/build-configmap.yaml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: build-configmap
|
||||||
|
namespace: NAME
|
||||||
|
labels:
|
||||||
|
app.kubernetes.part-of: NAME-website
|
||||||
|
data:
|
||||||
|
GITHOST: GITHOST
|
||||||
|
GITREPOURL: REPOURL
|
||||||
|
GITCOMMITURL: COMMITURL
|
|
@ -11,6 +11,7 @@ spec:
|
||||||
failedJobsHistoryLimit: 1
|
failedJobsHistoryLimit: 1
|
||||||
jobTemplate:
|
jobTemplate:
|
||||||
spec:
|
spec:
|
||||||
|
activeDeadlineSeconds: 415
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
namespace: NAME
|
namespace: NAME
|
||||||
|
@ -31,6 +32,8 @@ spec:
|
||||||
memory: BUILD_MEMORY_LIMIT
|
memory: BUILD_MEMORY_LIMIT
|
||||||
command: ["/entrypoint.sh"]
|
command: ["/entrypoint.sh"]
|
||||||
envFrom:
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: build-configmap
|
||||||
- secretRef:
|
- secretRef:
|
||||||
name: build-secret
|
name: build-secret
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
|
|
|
@ -7,5 +7,3 @@ metadata:
|
||||||
app.kubernetes.part-of: NAME-website
|
app.kubernetes.part-of: NAME-website
|
||||||
data:
|
data:
|
||||||
AUTHTOKEN: TOKEN
|
AUTHTOKEN: TOKEN
|
||||||
GITREPOURL: REPOURL
|
|
||||||
GITCOMMITURL: COMMITURL
|
|
||||||
|
|
|
@ -46,6 +46,8 @@ spec:
|
||||||
memory: BUILD_MEMORY_LIMIT
|
memory: BUILD_MEMORY_LIMIT
|
||||||
command: ["/entrypoint.sh"]
|
command: ["/entrypoint.sh"]
|
||||||
envFrom:
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: build-configmap
|
||||||
- secretRef:
|
- secretRef:
|
||||||
name: build-secret
|
name: build-secret
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
|
|
|
@ -30,12 +30,14 @@
|
||||||
[{:unique-name "example.io"
|
[{:unique-name "example.io"
|
||||||
:fqdns ["example.org", "www.example.com"]
|
:fqdns ["example.org", "www.example.com"]
|
||||||
:forgejo-host "finegitehost.net"
|
:forgejo-host "finegitehost.net"
|
||||||
:forgejo-repo "repo"
|
:repo-owner "someuser"
|
||||||
|
:repo-name "repo"
|
||||||
:branchname "main"}
|
:branchname "main"}
|
||||||
{:unique-name "test.io"
|
{:unique-name "test.io"
|
||||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"]
|
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"]
|
||||||
:forgejo-host "gitlab.de"
|
:forgejo-host "gitlab.de"
|
||||||
:forgejo-repo "repo"
|
:repo-owner "someuser"
|
||||||
|
:repo-name "repo"
|
||||||
:branchname "main"}]})
|
:branchname "main"}]})
|
||||||
|
|
||||||
(def websites2
|
(def websites2
|
||||||
|
@ -43,42 +45,40 @@
|
||||||
[{:unique-name "test.io"
|
[{:unique-name "test.io"
|
||||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"]
|
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"]
|
||||||
:forgejo-host "gitlab.de"
|
:forgejo-host "gitlab.de"
|
||||||
:forgejo-repo "repo"
|
:repo-owner "someuser"
|
||||||
|
:repo-name "repo"
|
||||||
:branchname "main"}
|
:branchname "main"}
|
||||||
{:unique-name "example.io"
|
{:unique-name "example.io"
|
||||||
:fqdns ["example.org", "www.example.com"]
|
:fqdns ["example.org", "www.example.com"]
|
||||||
:forgejo-host "finegitehost.net"
|
:forgejo-host "finegitehost.net"
|
||||||
:forgejo-repo "repo"
|
:repo-owner "someuser"
|
||||||
|
:repo-name "repo"
|
||||||
:branchname "main"}]})
|
:branchname "main"}]})
|
||||||
|
|
||||||
(def auth1
|
(def auth1
|
||||||
{:websiteauths
|
{:websiteauths
|
||||||
[{:unique-name "example.io"
|
[{:unique-name "example.io"
|
||||||
:username "someuser"
|
|
||||||
:authtoken "abedjgbasdodj"}
|
:authtoken "abedjgbasdodj"}
|
||||||
{:unique-name "test.io"
|
{:unique-name "test.io"
|
||||||
:username "someuser"
|
|
||||||
:authtoken "abedjgbasdodj"}]})
|
:authtoken "abedjgbasdodj"}]})
|
||||||
|
|
||||||
(def auth2
|
(def auth2
|
||||||
{:websiteauths
|
{:websiteauths
|
||||||
[{:unique-name "test.io"
|
[{:unique-name "test.io"
|
||||||
:username "someuser"
|
|
||||||
:authtoken "abedjgbasdodj"}
|
:authtoken "abedjgbasdodj"}
|
||||||
{:unique-name "example.io"
|
{:unique-name "example.io"
|
||||||
:username "someuser"
|
|
||||||
:authtoken "abedjgbasdodj"}]})
|
:authtoken "abedjgbasdodj"}]})
|
||||||
|
|
||||||
(def flattened-and-reduced-config
|
(def flattened-and-reduced-config
|
||||||
{:unique-name "example.io",
|
{:unique-name "example.io",
|
||||||
:fqdns ["example.org" "www.example.com"],
|
:fqdns ["example.org" "www.example.com"],
|
||||||
:forgejo-host "finegitehost.net",
|
:forgejo-host "finegitehost.net",
|
||||||
:forgejo-repo "repo",
|
:repo-owner "someuser",
|
||||||
|
:repo-name "repo",
|
||||||
:branchname "main"})
|
:branchname "main"})
|
||||||
|
|
||||||
(def flattened-and-reduced-auth
|
(def flattened-and-reduced-auth
|
||||||
{:unique-name "example.io",
|
{:unique-name "example.io",
|
||||||
:username "someuser",
|
|
||||||
:authtoken "abedjgbasdodj"})
|
:authtoken "abedjgbasdodj"})
|
||||||
|
|
||||||
(deftest sorts-config
|
(deftest sorts-config
|
||||||
|
@ -87,12 +87,14 @@
|
||||||
[{:unique-name "example.io",
|
[{:unique-name "example.io",
|
||||||
:fqdns ["example.org" "www.example.com"],
|
:fqdns ["example.org" "www.example.com"],
|
||||||
:forgejo-host "finegitehost.net",
|
:forgejo-host "finegitehost.net",
|
||||||
:forgejo-repo "repo",
|
:repo-owner "someuser",
|
||||||
|
:repo-name "repo",
|
||||||
:branchname "main"},
|
:branchname "main"},
|
||||||
{:unique-name "test.io",
|
{:unique-name "test.io",
|
||||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
||||||
:forgejo-host "gitlab.de",
|
:forgejo-host "gitlab.de",
|
||||||
:forgejo-repo "repo",
|
:repo-owner "someuser",
|
||||||
|
:repo-name "repo",
|
||||||
:branchname "main",
|
:branchname "main",
|
||||||
:sha256sum-output "123456789ab123cd345de script-file-name.sh"}],
|
:sha256sum-output "123456789ab123cd345de script-file-name.sh"}],
|
||||||
:mon-cfg {:grafana-cloud-url "url-for-your-prom-remote-write-endpoint", :cluster-name "jitsi", :cluster-stage "test"}}
|
:mon-cfg {:grafana-cloud-url "url-for-your-prom-remote-write-endpoint", :cluster-name "jitsi", :cluster-stage "test"}}
|
||||||
|
@ -102,13 +104,15 @@
|
||||||
[{:unique-name "test.io",
|
[{:unique-name "test.io",
|
||||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
||||||
:forgejo-host "gitlab.de",
|
:forgejo-host "gitlab.de",
|
||||||
:forgejo-repo "repo",
|
:repo-owner "someuser",
|
||||||
|
:repo-name "repo",
|
||||||
:branchname "main",
|
:branchname "main",
|
||||||
:sha256sum-output "123456789ab123cd345de script-file-name.sh"}
|
:sha256sum-output "123456789ab123cd345de script-file-name.sh"}
|
||||||
{:unique-name "example.io",
|
{:unique-name "example.io",
|
||||||
:fqdns ["example.org" "www.example.com"],
|
:fqdns ["example.org" "www.example.com"],
|
||||||
:forgejo-host "finegitehost.net",
|
:forgejo-host "finegitehost.net",
|
||||||
:forgejo-repo "repo",
|
:repo-owner "someuser",
|
||||||
|
:repo-name "repo",
|
||||||
:branchname "main"}],
|
:branchname "main"}],
|
||||||
:mon-cfg {:grafana-cloud-url "url-for-your-prom-remote-write-endpoint", :cluster-name "jitsi", :cluster-stage "test"}}))))
|
:mon-cfg {:grafana-cloud-url "url-for-your-prom-remote-write-endpoint", :cluster-name "jitsi", :cluster-stage "test"}}))))
|
||||||
|
|
||||||
|
@ -127,7 +131,7 @@
|
||||||
(cut/flatten-and-reduce-auth (cut/sort-auth auth2)))))
|
(cut/flatten-and-reduce-auth (cut/sort-auth auth2)))))
|
||||||
|
|
||||||
(deftest test-generate
|
(deftest test-generate
|
||||||
(is (= 22
|
(is (= 24
|
||||||
(count (cut/generate
|
(count (cut/generate
|
||||||
(yaml/load-as-edn "website-test/valid-config.yaml")
|
(yaml/load-as-edn "website-test/valid-config.yaml")
|
||||||
(yaml/load-as-edn "website-test/valid-auth.yaml"))))))
|
(yaml/load-as-edn "website-test/valid-auth.yaml"))))))
|
||||||
|
@ -158,13 +162,14 @@
|
||||||
:path "/",
|
:path "/",
|
||||||
:backend {:service {:name "test-io", :port {:number 80}}}}]}}]
|
:backend {:service {:name "test-io", :port {:number 80}}}}]}}]
|
||||||
(get-in
|
(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"],
|
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
||||||
:forgejo-repo "repo",
|
:forgejo-host "gitlab.de",
|
||||||
|
:repo-owner "someuser",
|
||||||
|
:repo-name "repo",
|
||||||
:sha256sum-output "123456789ab123cd345de script-file-name.sh",
|
:sha256sum-output "123456789ab123cd345de script-file-name.sh",
|
||||||
:issuer "staging",
|
:issuer "staging",
|
||||||
:branchname "main",
|
:branchname "main",
|
||||||
:unique-name "test.io"
|
|
||||||
:build-cpu-request "500m"
|
:build-cpu-request "500m"
|
||||||
:build-cpu-limit "1700m"
|
:build-cpu-limit "1700m"
|
||||||
:build-memory-request "256Mi"
|
:build-memory-request "256Mi"
|
||||||
|
@ -174,13 +179,14 @@
|
||||||
[2 :spec :rules])))
|
[2 :spec :rules])))
|
||||||
(is (= "test-io"
|
(is (= "test-io"
|
||||||
(get-in
|
(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"],
|
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
||||||
:forgejo-repo "repo",
|
:forgejo-host "gitlab.de",
|
||||||
|
:repo-owner "someuser",
|
||||||
|
:repo-name "repo",
|
||||||
:sha256sum-output "123456789ab123cd345de script-file-name.sh",
|
:sha256sum-output "123456789ab123cd345de script-file-name.sh",
|
||||||
:issuer "staging",
|
:issuer "staging",
|
||||||
:branchname "main",
|
:branchname "main",
|
||||||
:unique-name "test.io"
|
|
||||||
:build-cpu-request "500m"
|
:build-cpu-request "500m"
|
||||||
:build-cpu-limit "1700m"
|
:build-cpu-limit "1700m"
|
||||||
:build-memory-request "256Mi"
|
:build-memory-request "256Mi"
|
||||||
|
|
|
@ -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"
|
||||||
|
@ -31,7 +39,8 @@
|
||||||
:redirects [["/products.html", "/offer.html"]
|
:redirects [["/products.html", "/offer.html"]
|
||||||
["/one-more", "/redirect"]]
|
["/one-more", "/redirect"]]
|
||||||
:forgejo-host "gitea.evilorg",
|
:forgejo-host "gitea.evilorg",
|
||||||
:forgejo-repo "none",
|
:repo-owner "someuser",
|
||||||
|
:repo-name "none",
|
||||||
:branchname "mablain",
|
:branchname "mablain",
|
||||||
: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"]}
|
||||||
2)))
|
2)))
|
||||||
|
@ -45,7 +54,8 @@
|
||||||
:unique-name "test.io",
|
:unique-name "test.io",
|
||||||
:redirects []
|
:redirects []
|
||||||
:forgejo-host "gitea.evilorg",
|
:forgejo-host "gitea.evilorg",
|
||||||
:forgejo-repo "none",
|
:repo-owner "someuser",
|
||||||
|
:repo-name "none",
|
||||||
:branchname "mablain",
|
:branchname "mablain",
|
||||||
: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"]}
|
||||||
0))))
|
0))))
|
||||||
|
@ -54,8 +64,9 @@
|
||||||
(deftest should-generate-resource-requests
|
(deftest should-generate-resource-requests
|
||||||
(is (= {:requests {:cpu "1500m", :memory "512Mi"}, :limits {:cpu "3000m", :memory "1024Mi"}}
|
(is (= {:requests {:cpu "1500m", :memory "512Mi"}, :limits {:cpu "3000m", :memory "1024Mi"}}
|
||||||
(-> (cut/generate-nginx-deployment {:forgejo-host "gitlab.de",
|
(-> (cut/generate-nginx-deployment {:forgejo-host "gitlab.de",
|
||||||
|
:repo-owner "someuser",
|
||||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
||||||
:forgejo-repo "repo",
|
:repo-name "repo",
|
||||||
:issuer "staging",
|
:issuer "staging",
|
||||||
:branchname "main",
|
:branchname "main",
|
||||||
:unique-name "test.io",
|
:unique-name "test.io",
|
||||||
|
@ -68,8 +79,9 @@
|
||||||
:spec :template :spec :initContainers first :resources)))
|
:spec :template :spec :initContainers first :resources)))
|
||||||
(is (= "test-io"
|
(is (= "test-io"
|
||||||
(-> (cut/generate-nginx-deployment {:forgejo-host "gitlab.de",
|
(-> (cut/generate-nginx-deployment {:forgejo-host "gitlab.de",
|
||||||
|
:repo-owner "someuser",
|
||||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
||||||
:forgejo-repo "repo",
|
:repo-name "repo",
|
||||||
:issuer "staging",
|
:issuer "staging",
|
||||||
:branchname "main",
|
:branchname "main",
|
||||||
:unique-name "test.io",
|
:unique-name "test.io",
|
||||||
|
@ -92,7 +104,8 @@
|
||||||
:redirects [["/products.html", "/offer.html"]
|
:redirects [["/products.html", "/offer.html"]
|
||||||
["/one-more", "/redirect"]]
|
["/one-more", "/redirect"]]
|
||||||
:forgejo-host "gitea.evilorg",
|
:forgejo-host "gitea.evilorg",
|
||||||
:forgejo-repo "none",
|
:repo-owner "someuser",
|
||||||
|
:repo-name "none",
|
||||||
:branchname "mablain",
|
:branchname "mablain",
|
||||||
: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"]})))
|
||||||
" /offer.html permanent;\n"))
|
" /offer.html permanent;\n"))
|
||||||
|
@ -107,7 +120,8 @@
|
||||||
:redirects [["/products.html", "/offer.html"]
|
:redirects [["/products.html", "/offer.html"]
|
||||||
["/one-more", "/redirect"]]
|
["/one-more", "/redirect"]]
|
||||||
:forgejo-host "gitea.evilorg",
|
:forgejo-host "gitea.evilorg",
|
||||||
:forgejo-repo "none",
|
:repo-owner "someuser",
|
||||||
|
:repo-name "none",
|
||||||
:branchname "mablain",
|
:branchname "mablain",
|
||||||
: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"]})))
|
||||||
" /redirect permanent;\n"))
|
" /redirect permanent;\n"))
|
||||||
|
@ -121,7 +135,8 @@
|
||||||
:unique-name "test.io",
|
:unique-name "test.io",
|
||||||
:redirects [],
|
:redirects [],
|
||||||
:forgejo-host "gitea.evilorg",
|
:forgejo-host "gitea.evilorg",
|
||||||
:forgejo-repo "none",
|
:repo-owner "someuser",
|
||||||
|
:repo-name "none",
|
||||||
:branchname "mablain",
|
:branchname "mablain",
|
||||||
: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"]})))
|
||||||
"server_name test.de www.test.de test-it.de www.test-it.de;"))
|
"server_name test.de www.test.de test-it.de www.test-it.de;"))
|
||||||
|
@ -139,7 +154,8 @@
|
||||||
:unique-name "test.io",
|
:unique-name "test.io",
|
||||||
:redirects [],
|
:redirects [],
|
||||||
:forgejo-host "gitea.evilorg",
|
:forgejo-host "gitea.evilorg",
|
||||||
:forgejo-repo "none",
|
:repo-owner "someuser",
|
||||||
|
:repo-name "none",
|
||||||
:branchname "mablain",
|
:branchname "mablain",
|
||||||
: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"]})
|
||||||
:data))))
|
:data))))
|
||||||
|
@ -162,7 +178,8 @@
|
||||||
:unique-name "test.io",
|
:unique-name "test.io",
|
||||||
:redirects [],
|
:redirects [],
|
||||||
:forgejo-host "gitea.evilorg",
|
:forgejo-host "gitea.evilorg",
|
||||||
:forgejo-repo "none",
|
:repo-owner "someuser",
|
||||||
|
:repo-name "none",
|
||||||
:branchname "mablain",
|
:branchname "mablain",
|
||||||
: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"]}))))
|
||||||
|
|
||||||
|
@ -179,7 +196,8 @@
|
||||||
:failedJobsHistoryLimit 1,
|
:failedJobsHistoryLimit 1,
|
||||||
:jobTemplate
|
:jobTemplate
|
||||||
{:spec
|
{:spec
|
||||||
{:template
|
{:activeDeadlineSeconds 415,
|
||||||
|
:template
|
||||||
{:metadata
|
{:metadata
|
||||||
{:namespace "test-io",
|
{:namespace "test-io",
|
||||||
:labels
|
:labels
|
||||||
|
@ -191,7 +209,8 @@
|
||||||
:imagePullPolicy "IfNotPresent",
|
:imagePullPolicy "IfNotPresent",
|
||||||
:resources {:requests {:cpu "500m", :memory "256Mi"}, :limits {:cpu "1700m", :memory "512Mi"}},
|
:resources {:requests {:cpu "500m", :memory "256Mi"}, :limits {:cpu "1700m", :memory "512Mi"}},
|
||||||
:command ["/entrypoint.sh"],
|
:command ["/entrypoint.sh"],
|
||||||
:envFrom [{:secretRef {:name "build-secret"}}],
|
:envFrom [{:configMapRef {:name "build-configmap"}}
|
||||||
|
{:secretRef {:name "build-secret"}}],
|
||||||
:volumeMounts [{:name "content-volume", :mountPath "/var/www/html/website"}
|
:volumeMounts [{:name "content-volume", :mountPath "/var/www/html/website"}
|
||||||
{:name "hash-state-volume", :mountPath "/var/hashfile.d"}]}],
|
{:name "hash-state-volume", :mountPath "/var/hashfile.d"}]}],
|
||||||
:volumes [{:name "content-volume", :persistentVolumeClaim {:claimName "content-volume"}}
|
:volumes [{:name "content-volume", :persistentVolumeClaim {:claimName "content-volume"}}
|
||||||
|
@ -204,12 +223,37 @@
|
||||||
:build-memory-limit "512Mi"
|
:build-memory-limit "512Mi"
|
||||||
:volume-size "3"
|
:volume-size "3"
|
||||||
:forgejo-host "gitlab.de",
|
:forgejo-host "gitlab.de",
|
||||||
|
:repo-owner "someuser",
|
||||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
||||||
:forgejo-repo "repo",
|
:repo-name "repo",
|
||||||
:branchname "main",
|
:branchname "main",
|
||||||
: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
|
||||||
|
{:GITHOST "mygit.de"
|
||||||
|
: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-owner "someuser",
|
||||||
|
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
||||||
|
:repo-name "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",
|
||||||
|
@ -217,24 +261,9 @@
|
||||||
:namespace "test-io",
|
:namespace "test-io",
|
||||||
:labels {:app.kubernetes.part-of "test-io-website"}},
|
:labels {:app.kubernetes.part-of "test-io-website"}},
|
||||||
:data
|
:data
|
||||||
{:AUTHTOKEN "YWJlZGpnYmFzZG9kag==",
|
{:AUTHTOKEN "YWJlZGpnYmFzZG9kag=="}}
|
||||||
:GITREPOURL "aHR0cHM6Ly9naXRsYWIuZGUvYXBpL3YxL3JlcG9zL3NvbWV1c2VyL3JlcG8vYXJjaGl2ZS9tYWluLnppcA==",
|
(cut/generate-build-secret {:unique-name "test.io",
|
||||||
:GITCOMMITURL "aHR0cHM6Ly9naXRsYWIuZGUvYXBpL3YxL3JlcG9zL3NvbWV1c2VyL3JlcG8vZ2l0L2NvbW1pdHMvSEVBRA=="}}
|
:authtoken "abedjgbasdodj"}))))
|
||||||
(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"
|
|
||||||
: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"}))))
|
|
||||||
|
|
||||||
(deftest should-generate-content-pvc
|
(deftest should-generate-content-pvc
|
||||||
(is (= {:apiVersion "v1",
|
(is (= {:apiVersion "v1",
|
||||||
|
@ -256,7 +285,8 @@
|
||||||
:unique-name "test.io",
|
:unique-name "test.io",
|
||||||
:redirects [],
|
:redirects [],
|
||||||
:forgejo-host "gitea.evilorg",
|
:forgejo-host "gitea.evilorg",
|
||||||
:forgejo-repo "none",
|
:repo-owner "someuser",
|
||||||
|
:repo-name "none",
|
||||||
:branchname "mablain",
|
:branchname "mablain",
|
||||||
: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"]}))))
|
||||||
|
|
||||||
|
@ -280,6 +310,7 @@
|
||||||
:unique-name "test.io",
|
:unique-name "test.io",
|
||||||
:redirects [],
|
:redirects [],
|
||||||
:forgejo-host "gitea.evilorg",
|
:forgejo-host "gitea.evilorg",
|
||||||
:forgejo-repo "none",
|
:repo-owner "someuser",
|
||||||
|
:repo-name "none",
|
||||||
:branchname "mablain",
|
:branchname "mablain",
|
||||||
: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"]}))))
|
|
@ -1,9 +1,7 @@
|
||||||
websiteauths:
|
websiteauths:
|
||||||
- unique-name: "test.io"
|
- unique-name: "test.io"
|
||||||
username: "someuser"
|
|
||||||
authtoken: "abedjgbasdodj"
|
authtoken: "abedjgbasdodj"
|
||||||
- unique-name: "example.io"
|
- unique-name: "example.io"
|
||||||
username: "someuser"
|
|
||||||
authtoken: "abedjgbasdodj"
|
authtoken: "abedjgbasdodj"
|
||||||
mon-auth:
|
mon-auth:
|
||||||
grafana-cloud-user: "user"
|
grafana-cloud-user: "user"
|
||||||
|
|
|
@ -3,14 +3,20 @@ websiteconfigs:
|
||||||
- unique-name: "test.io"
|
- unique-name: "test.io"
|
||||||
fqdns: ["test.de", "test.org", "www.test.de", "www.test.org"]
|
fqdns: ["test.de", "test.org", "www.test.de", "www.test.org"]
|
||||||
forgejo-host: "codeberg.org"
|
forgejo-host: "codeberg.org"
|
||||||
forgejo-repo: "repo"
|
repo-owner: "someuser"
|
||||||
|
repo-name: "repo"
|
||||||
branchname: "main"
|
branchname: "main"
|
||||||
|
redirects:
|
||||||
|
- ["/products.html", "/offer.html"]
|
||||||
|
- ["/one-more", "/redirect"]
|
||||||
- unique-name: "example.io"
|
- unique-name: "example.io"
|
||||||
fqdns: ["example.org", "www.example.com"]
|
fqdns: ["example.org", "www.example.com"]
|
||||||
forgejo-host: "fineForgejoHost.net"
|
forgejo-host: "fineForgejoHost.net"
|
||||||
forgejo-repo: "repo"
|
repo-owner: "someotheruser"
|
||||||
|
repo-name: "repo"
|
||||||
branchname: "main"
|
branchname: "main"
|
||||||
mon-cfg:
|
mon-cfg:
|
||||||
grafana-cloud-url: "url-for-your-prom-remote-write-endpoint"
|
grafana-cloud-url: "url-for-your-prom-remote-write-endpoint"
|
||||||
cluster-name: "website"
|
cluster-name: "website"
|
||||||
cluster-stage: "test"
|
cluster-stage: "test"
|
||||||
|
average-rate: 50
|
||||||
|
|
Loading…
Reference in a new issue