From 91d88d2a689739f9820865857769e655aa714294 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 3 Feb 2023 10:14:34 +0100 Subject: [PATCH] Use nextcloud instead of jitsi --- src/main/clj/dda/c4k_nextcloud/uberjar.clj | 6 +- src/main/cljc/dda/c4k_nextcloud/core.cljc | 37 +++++----- .../cljc/dda/c4k_nextcloud/core_test.cljc | 67 +++++-------------- 3 files changed, 38 insertions(+), 72 deletions(-) diff --git a/src/main/clj/dda/c4k_nextcloud/uberjar.clj b/src/main/clj/dda/c4k_nextcloud/uberjar.clj index 73c4c40..4983f70 100644 --- a/src/main/clj/dda/c4k_nextcloud/uberjar.clj +++ b/src/main/clj/dda/c4k_nextcloud/uberjar.clj @@ -2,14 +2,14 @@ (:gen-class) (:require [dda.c4k-common.uberjar :as uberjar] - [dda.c4k-nextcloud.jitsi :as jitsi] + [dda.c4k-nextcloud.nextcloud :as nextcloud] [dda.c4k-nextcloud.core :as core])) (defn -main [& cmd-args] (uberjar/main-common "c4k-nextcloud" - jitsi/config? - jitsi/auth? + nextcloud/config? + nextcloud/auth? core/config-defaults core/generate cmd-args)) diff --git a/src/main/cljc/dda/c4k_nextcloud/core.cljc b/src/main/cljc/dda/c4k_nextcloud/core.cljc index a04bd42..27045f2 100644 --- a/src/main/cljc/dda/c4k_nextcloud/core.cljc +++ b/src/main/cljc/dda/c4k_nextcloud/core.cljc @@ -17,25 +17,24 @@ [config (s/merge nextcloud/config? nextcloud/auth?)] (let [nextcloud-default-storage-config {:pvc-storage-class-name default-storage-class :pv-storage-size-gb 200}] - (into - [] - (concat [(yaml/to-string (postgres/generate-config {:postgres-size :8gb})) - (yaml/to-string (postgres/generate-secret config)) - (yaml/to-string (postgres/generate-pvc {:pv-storage-size-gb 50 - :pvc-storage-class-name default-storage-class})) - (yaml/to-string (postgres/generate-deployment)) - (yaml/to-string (postgres/generate-service)) - (yaml/to-string (nextcloud/generate-secret config)) - (yaml/to-string (nextcloud/generate-pvc (merge nextcloud-default-storage-config config))) - (yaml/to-string (nextcloud/generate-deployment config)) - (yaml/to-string (nextcloud/generate-service)) - (yaml/to-string (nextcloud/generate-certificate config)) - (yaml/to-string (nextcloud/generate-ingress config))] - (when (contains? config :restic-repository) - [(yaml/to-string (backup/generate-config config)) - (yaml/to-string (backup/generate-secret config)) - (yaml/to-string (backup/generate-cron)) - (yaml/to-string (backup/generate-backup-restore-deployment config))]))))) + (map yaml/to-string + [(postgres/generate-config {:postgres-size :8gb}) + (postgres/generate-secret config) + (postgres/generate-pvc {:pv-storage-size-gb 50 + :pvc-storage-class-name default-storage-class}) + (postgres/generate-deployment) + (postgres/generate-service) + (nextcloud/generate-secret config) + (nextcloud/generate-pvc (merge nextcloud-default-storage-config config)) + (nextcloud/generate-deployment config) + (nextcloud/generate-service) + (nextcloud/generate-certificate config) + (nextcloud/generate-ingress config)] + (when (:contains? config :restic-repository) + [(backup/generate-config config) + (backup/generate-secret config) + (backup/generate-cron) + (backup/generate-backup-restore-deployment config)])))) (defn-spec generate any? [my-config nextcloud/config? diff --git a/src/test/cljc/dda/c4k_nextcloud/core_test.cljc b/src/test/cljc/dda/c4k_nextcloud/core_test.cljc index d4fbda6..0c88290 100644 --- a/src/test/cljc/dda/c4k_nextcloud/core_test.cljc +++ b/src/test/cljc/dda/c4k_nextcloud/core_test.cljc @@ -2,54 +2,21 @@ (:require #?(:clj [clojure.test :refer [deftest is are testing run-tests]] :cljs [cljs.test :refer-macros [deftest is are testing run-tests]]) - [clojure.string :as st] - [dda.c4k-nextcloud.core :as cut] - )) + #?(:cljs [shadow-resource :as rc]) + [clojure.spec.alpha :as s] + [dda.c4k-common.yaml :as yaml] + [dda.c4k-nextcloud.core :as cut])) -(deftest should-k8s-objects - (is (= 15 - (count (cut/k8s-objects {:fqdn "nextcloud-neu.prod.meissa-gmbh.de" - :postgres-db-user "nextcloud" - :postgres-db-password "nextcloud-db-password" - :nextcloud-admin-user "cloudadmin" - :nextcloud-admin-password "cloudpassword" - :issuer "prod" - :aws-access-key-id "aws-id" - :aws-secret-access-key "aws-secret" - :restic-password "restic-pw" - :restic-repository "restic-repository"})))) - (is (= 11 - (count (cut/k8s-objects {:fqdn "nextcloud-neu.prod.meissa-gmbh.de" - :postgres-db-user "nextcloud" - :postgres-db-password "nextcloud-db-password" - :nextcloud-admin-user "cloudadmin" - :nextcloud-admin-password "cloudpassword" - :issuer "prod" - :aws-access-key-id "aws-id" - :aws-secret-access-key "aws-secret" - :restic-password "restic-pw"})))) - (is (st/includes? - (get-in (cut/k8s-objects {:fqdn "nextcloud-neu.prod.meissa-gmbh.de" - :postgres-db-user "nextcloud" - :postgres-db-password "nextcloud-db-password" - :nextcloud-admin-user "cloudadmin" - :nextcloud-admin-password "cloudpassword" - :issuer "prod" - :aws-access-key-id "aws-id" - :aws-secret-access-key "aws-secret" - :restic-password "restic-pw"}) - [0]) - "max_connections = 700")) - (is (st/includes? - (get-in (cut/k8s-objects {:fqdn "nextcloud-neu.prod.meissa-gmbh.de" - :postgres-db-user "nextcloud" - :postgres-db-password "nextcloud-db-password" - :nextcloud-admin-user "cloudadmin" - :nextcloud-admin-password "cloudpassword" - :issuer "prod" - :aws-access-key-id "aws-id" - :aws-secret-access-key "aws-secret" - :restic-password "restic-pw"}) - [6]) - "storageClassName: local-path")) -) +#?(:cljs + (defmethod yaml/load-resource :nextcloud-test [resource-name] + (case resource-name + "nextcloud-test/valid-auth.yaml" (rc/inline "nextcloud-test/valid-auth.yaml") + "nextcloud-test/valid-config.yaml" (rc/inline "nextcloud-test/valid-config.yaml") + "nextcloud-test/invalid-auth.yaml" (rc/inline "nextcloud-test/invalid-auth.yaml") + "nextcloud-test/invalid-config.yaml" (rc/inline "nextcloud-test/invalid-config.yaml")))) + +(deftest validate-valid-resources + (is (s/valid? cut/config? (yaml/load-as-edn "nextcloud-test/valid-config.yaml"))) + (is (s/valid? cut/auth? (yaml/load-as-edn "nextcloud-test/valid-auth.yaml"))) + (is (not (s/valid? cut/config? (yaml/load-as-edn "nextcloud-test/invalid-config.yaml")))) + (is (not (s/valid? cut/auth? (yaml/load-as-edn "nextcloud-test/invalid-auth.yaml")))))