feature/introduce-namespaces #3

Merged
jem merged 11 commits from feature/introduce-namespaces into main 2024-02-27 10:13:49 +00:00
6 changed files with 42 additions and 21 deletions
Showing only changes of commit 5d3621f6f8 - Show all commits

View file

@ -20,19 +20,19 @@
(def auth? (s/keys :req-un [::website/auth]
:opt-un [::mon-auth]))
(defn-spec sort-config cp/map-or-seq?
(defn-spec sort-config map?
[unsorted-config config?]
(let [sorted-websites (into [] (sort-by :unique-name (unsorted-config :websites)))]
(-> unsorted-config
(assoc-in [:websites] sorted-websites))))
(defn-spec sort-auth cp/map-or-seq?
(defn-spec sort-auth map?
[unsorted-auth auth?]
(let [sorted-auth (into [] (sort-by :unique-name (unsorted-auth :auth)))]
(-> unsorted-auth
(assoc-in [:auth] sorted-auth))))
(defn-spec flatten-and-reduce-config cp/map-or-seq?
(defn-spec flatten-and-reduce-config map?
[config config?]
(let
[first-entry (first (:websites config))]
@ -42,7 +42,7 @@
(when (contains? config :volume-size)
{:volume-size (config :volume-size)}))))
(defn-spec flatten-and-reduce-auth cp/map-or-seq?
(defn-spec flatten-and-reduce-auth map?
[auth auth?]
(-> auth :auth first))

View file

@ -1,7 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: etc-ngingx
name: etc-nginx
namespace: default
labels:
app.kubernetes.part-of: NAME-website

View file

@ -1,23 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: NAME-deployment
namespace: webserver
name: nginx
namespace: NAME
labels:
app.kubernetes.part-of: NAME-website
spec:
replicas: 1
selector:
matchLabels:
app: NAME-nginx
app: nginx
template:
metadata:
namespace: webserver
namespace: NAME
labels:
app: NAME-nginx
app: nginx
app.kubernetes.part-of: NAME-website
spec:
containers:
- name: NAME-nginx
- name: nginx
image: nginx:latest
imagePullPolicy: IfNotPresent
ports:
@ -33,7 +34,7 @@ spec:
readOnly: true
initContainers:
- image: domaindrivenarchitecture/c4k-website-build
name: NAME-init-build-container
name: init-build-container
imagePullPolicy: IfNotPresent
resources:
requests:
@ -45,16 +46,16 @@ spec:
command: ["/entrypoint.sh"]
envFrom:
- secretRef:
name: NAME-secret
name: secret
volumeMounts:
- name: content-volume
mountPath: /var/www/html/website
- name: hashfile-volume
- name: hash-state-volume
mountPath: /var/hashfile.d
volumes:
- name: etc-ngingx
- name: etc-nginx
configMap:
name: etc-ngingx
name: etc-nginx
items:
- key: nginx.conf
path: nginx.conf
@ -66,8 +67,8 @@ spec:
emptyDir: {}
- name: content-volume
persistentVolumeClaim:
claimName: NAME-content-volume
- name: hashfile-volume
claimName: content-volume
- name: hash-state-volume
persistentVolumeClaim:
claimName: NAME-hashfile-volume
claimName: hash-state-volume

View file

@ -4,9 +4,15 @@
#?(:clj [clojure.test :refer [deftest is are testing run-tests]]
:cljs [cljs.test :refer-macros [deftest is are testing run-tests]])
[clojure.spec.alpha :as s]
[clojure.spec.test.alpha :as st]
[dda.c4k-common.yaml :as yaml]
[dda.c4k-website.core :as cut]))
(st/instrument `cut/sort-config)
(st/instrument `cut/flattened-and-reduced-config)
(st/instrument `cut/flatten-and-reduce-auth)
(st/instrument `cut/generate)
#?(:cljs
(defmethod yaml/load-resource :website-test [resource-name]
(case resource-name

View file

@ -28,7 +28,20 @@
:build-memory-request "512Mi"
:build-memory-limit "1024Mi"
:volume-size 3})
:spec :template :spec :initContainers first :resources))))
:spec :template :spec :initContainers first :resources)))
(is (= "test-io"
(-> (cut/generate-nginx-deployment {:forgejo-host "gitlab.de",
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
:forgejo-repo "repo",
:issuer "staging",
:branchname "main",
:unique-name "test.io"
:build-cpu-request "1500m"
:build-cpu-limit "3000m"
:build-memory-request "512Mi"
:build-memory-limit "1024Mi"
:volume-size 3})
:metadata :namespace))))
(deftest should-generate-nginx-configmap-website

View file

@ -3,9 +3,10 @@
#?(:clj [clojure.test :refer [deftest is are testing run-tests]]
:cljs [cljs.test :refer-macros [deftest is are testing run-tests]])
[clojure.spec.test.alpha :as st]
[dda.c4k-common.test-helper :as th]
[dda.c4k-website.website :as cut]))
(st/instrument `cut/generate-ingress)
(deftest should-generate-ingress
(is (= [{:host "test.de",
:http