From 4764d1db67895f00e8a7963d385da8363665947c Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 31 May 2024 16:43:06 +0200 Subject: [PATCH] use the new pcv defaults --- src/main/cljc/dda/c4k_nextcloud/core.cljc | 58 +++++++++++------------ 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/src/main/cljc/dda/c4k_nextcloud/core.cljc b/src/main/cljc/dda/c4k_nextcloud/core.cljc index a6b3186..9d7cfdb 100644 --- a/src/main/cljc/dda/c4k_nextcloud/core.cljc +++ b/src/main/cljc/dda/c4k_nextcloud/core.cljc @@ -1,45 +1,43 @@ (ns dda.c4k-nextcloud.core - (:require - #?(:clj [orchestra.core :refer [defn-spec]] - :cljs [orchestra.core :refer-macros [defn-spec]]) - [dda.c4k-common.common :as cm] - [dda.c4k-common.predicate :as cp] - [dda.c4k-common.yaml :as yaml] - [dda.c4k-common.postgres :as postgres] - [dda.c4k-nextcloud.nextcloud :as nextcloud] - [dda.c4k-nextcloud.backup :as backup] - [dda.c4k-common.monitoring :as mon] - [dda.c4k-common.namespace :as ns])) + (:require + #?(:clj [orchestra.core :refer [defn-spec]] + :cljs [orchestra.core :refer-macros [defn-spec]]) + [dda.c4k-common.common :as cm] + [dda.c4k-common.predicate :as cp] + [dda.c4k-common.yaml :as yaml] + [dda.c4k-common.postgres :as postgres] + [dda.c4k-nextcloud.nextcloud :as nextcloud] + [dda.c4k-nextcloud.backup :as backup] + [dda.c4k-common.monitoring :as mon] + [dda.c4k-common.namespace :as ns])) -(def default-storage-class "local-path") - -(def config-defaults {:issuer "staging"}) +(def config-defaults {:namespace "nextcloud" + :issuer "staging" + :pvc-storage-class-name "hcloud-volumes-encrypted" + :pv-storage-size-gb 200}) (defn-spec k8s-objects cp/map-or-seq? [config nextcloud/config? auth nextcloud/auth?] - (let [nextcloud-default-storage-config {:pvc-storage-class-name default-storage-class - :pv-storage-size-gb 200}] + (let [resolved-config (merge config-defaults config)] (map yaml/to-string (filter #(not (nil? %)) (cm/concat-vec - (ns/generate (merge {:namespace "nextcloud"} config)) - (postgres/generate {:postgres-size :8gb - :db-name "cloud" - :pv-storage-size-gb 50 - :pvc-storage-class-name default-storage-class - :namespace "nextcloud"} + (ns/generate resolved-config) + (postgres/generate (merge resolved-config {:postgres-size :8gb + :db-name "cloud" + :pv-storage-size-gb 50}) auth) [(nextcloud/generate-secret auth) - (nextcloud/generate-pvc (merge nextcloud-default-storage-config config)) - (nextcloud/generate-deployment config) + (nextcloud/generate-pvc resolved-config) + (nextcloud/generate-deployment resolved-config) (nextcloud/generate-service)] - (nextcloud/generate-ingress-and-cert (merge {:namespace "nextcloud"} config)) - (when (:contains? config :restic-repository) - [(backup/generate-config config) + (nextcloud/generate-ingress-and-cert resolved-config) + (when (:contains? resolved-config :restic-repository) + [(backup/generate-config resolved-config) (backup/generate-secret auth) (backup/generate-cron) - (backup/generate-backup-restore-deployment config)]) - (when (:contains? config :mon-cfg) - (mon/generate (:mon-cfg config) (:mon-auth auth)))))))) + (backup/generate-backup-restore-deployment resolved-config)]) + (when (:contains? resolved-config :mon-cfg) + (mon/generate (:mon-cfg resolved-config) (:mon-auth auth))))))))