feature/introduce-namespaces #3
6 changed files with 42 additions and 21 deletions
|
@ -20,19 +20,19 @@
|
||||||
(def auth? (s/keys :req-un [::website/auth]
|
(def auth? (s/keys :req-un [::website/auth]
|
||||||
:opt-un [::mon-auth]))
|
:opt-un [::mon-auth]))
|
||||||
|
|
||||||
(defn-spec sort-config cp/map-or-seq?
|
(defn-spec sort-config map?
|
||||||
[unsorted-config config?]
|
[unsorted-config config?]
|
||||||
(let [sorted-websites (into [] (sort-by :unique-name (unsorted-config :websites)))]
|
(let [sorted-websites (into [] (sort-by :unique-name (unsorted-config :websites)))]
|
||||||
(-> unsorted-config
|
(-> unsorted-config
|
||||||
(assoc-in [:websites] sorted-websites))))
|
(assoc-in [:websites] sorted-websites))))
|
||||||
|
|
||||||
(defn-spec sort-auth cp/map-or-seq?
|
(defn-spec sort-auth map?
|
||||||
[unsorted-auth auth?]
|
[unsorted-auth auth?]
|
||||||
(let [sorted-auth (into [] (sort-by :unique-name (unsorted-auth :auth)))]
|
(let [sorted-auth (into [] (sort-by :unique-name (unsorted-auth :auth)))]
|
||||||
(-> unsorted-auth
|
(-> unsorted-auth
|
||||||
(assoc-in [:auth] sorted-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?]
|
[config config?]
|
||||||
(let
|
(let
|
||||||
[first-entry (first (:websites config))]
|
[first-entry (first (:websites config))]
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
(when (contains? config :volume-size)
|
(when (contains? config :volume-size)
|
||||||
{:volume-size (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?]
|
||||||
(-> auth :auth first))
|
(-> auth :auth first))
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
name: etc-ngingx
|
name: etc-nginx
|
||||||
namespace: default
|
namespace: default
|
||||||
labels:
|
labels:
|
||||||
app.kubernetes.part-of: NAME-website
|
app.kubernetes.part-of: NAME-website
|
||||||
|
|
|
@ -1,23 +1,24 @@
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: NAME-deployment
|
name: nginx
|
||||||
namespace: webserver
|
namespace: NAME
|
||||||
labels:
|
labels:
|
||||||
app.kubernetes.part-of: NAME-website
|
app.kubernetes.part-of: NAME-website
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: NAME-nginx
|
app: nginx
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
namespace: webserver
|
namespace: NAME
|
||||||
labels:
|
labels:
|
||||||
app: NAME-nginx
|
app: nginx
|
||||||
|
app.kubernetes.part-of: NAME-website
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: NAME-nginx
|
- name: nginx
|
||||||
image: nginx:latest
|
image: nginx:latest
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
ports:
|
ports:
|
||||||
|
@ -33,7 +34,7 @@ spec:
|
||||||
readOnly: true
|
readOnly: true
|
||||||
initContainers:
|
initContainers:
|
||||||
- image: domaindrivenarchitecture/c4k-website-build
|
- image: domaindrivenarchitecture/c4k-website-build
|
||||||
name: NAME-init-build-container
|
name: init-build-container
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
|
@ -45,16 +46,16 @@ spec:
|
||||||
command: ["/entrypoint.sh"]
|
command: ["/entrypoint.sh"]
|
||||||
envFrom:
|
envFrom:
|
||||||
- secretRef:
|
- secretRef:
|
||||||
name: NAME-secret
|
name: secret
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: content-volume
|
- name: content-volume
|
||||||
mountPath: /var/www/html/website
|
mountPath: /var/www/html/website
|
||||||
- name: hashfile-volume
|
- name: hash-state-volume
|
||||||
mountPath: /var/hashfile.d
|
mountPath: /var/hashfile.d
|
||||||
volumes:
|
volumes:
|
||||||
- name: etc-ngingx
|
- name: etc-nginx
|
||||||
configMap:
|
configMap:
|
||||||
name: etc-ngingx
|
name: etc-nginx
|
||||||
items:
|
items:
|
||||||
- key: nginx.conf
|
- key: nginx.conf
|
||||||
path: nginx.conf
|
path: nginx.conf
|
||||||
|
@ -66,8 +67,8 @@ spec:
|
||||||
emptyDir: {}
|
emptyDir: {}
|
||||||
- name: content-volume
|
- name: content-volume
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: NAME-content-volume
|
claimName: content-volume
|
||||||
- name: hashfile-volume
|
- name: hash-state-volume
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: NAME-hashfile-volume
|
claimName: hash-state-volume
|
||||||
|
|
|
@ -4,9 +4,15 @@
|
||||||
#?(:clj [clojure.test :refer [deftest is are testing run-tests]]
|
#?(:clj [clojure.test :refer [deftest is are testing run-tests]]
|
||||||
:cljs [cljs.test :refer-macros [deftest is are testing run-tests]])
|
:cljs [cljs.test :refer-macros [deftest is are testing run-tests]])
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
|
[clojure.spec.test.alpha :as st]
|
||||||
[dda.c4k-common.yaml :as yaml]
|
[dda.c4k-common.yaml :as yaml]
|
||||||
[dda.c4k-website.core :as cut]))
|
[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
|
#?(:cljs
|
||||||
(defmethod yaml/load-resource :website-test [resource-name]
|
(defmethod yaml/load-resource :website-test [resource-name]
|
||||||
(case resource-name
|
(case resource-name
|
||||||
|
|
|
@ -28,7 +28,20 @@
|
||||||
:build-memory-request "512Mi"
|
:build-memory-request "512Mi"
|
||||||
:build-memory-limit "1024Mi"
|
:build-memory-limit "1024Mi"
|
||||||
:volume-size 3})
|
: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
|
(deftest should-generate-nginx-configmap-website
|
||||||
|
|
|
@ -3,9 +3,10 @@
|
||||||
#?(:clj [clojure.test :refer [deftest is are testing run-tests]]
|
#?(:clj [clojure.test :refer [deftest is are testing run-tests]]
|
||||||
:cljs [cljs.test :refer-macros [deftest is are testing run-tests]])
|
:cljs [cljs.test :refer-macros [deftest is are testing run-tests]])
|
||||||
[clojure.spec.test.alpha :as st]
|
[clojure.spec.test.alpha :as st]
|
||||||
[dda.c4k-common.test-helper :as th]
|
|
||||||
[dda.c4k-website.website :as cut]))
|
[dda.c4k-website.website :as cut]))
|
||||||
|
|
||||||
|
(st/instrument `cut/generate-ingress)
|
||||||
|
|
||||||
(deftest should-generate-ingress
|
(deftest should-generate-ingress
|
||||||
(is (= [{:host "test.de",
|
(is (= [{:host "test.de",
|
||||||
:http
|
:http
|
||||||
|
|
Loading…
Reference in a new issue