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]
|
||||
: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))
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: etc-ngingx
|
||||
name: etc-nginx
|
||||
namespace: default
|
||||
labels:
|
||||
app.kubernetes.part-of: NAME-website
|
||||
|
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue