use the new pcv defaults

This commit is contained in:
Michael Jerger 2024-05-31 16:43:06 +02:00
parent 8aef785bdc
commit 4764d1db67

View file

@ -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))))))))