diff --git a/package.json b/package.json index 243ace4..2c294e4 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "c4k-nextcloud", "description": "Generate c4k yaml for a nextcloud deployment.", "author": "meissa GmbH", - "version": "3.4.2-SNAPSHOT", + "version": "4.0.0-SNAPSHOT", "homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-nextcloud#readme", "repository": "https://www.npmjs.com/package/c4k-nextcloud", "license": "APACHE2", diff --git a/project.clj b/project.clj index 3586d30..7e0c5f8 100644 --- a/project.clj +++ b/project.clj @@ -1,11 +1,11 @@ -(defproject org.domaindrivenarchitecture/c4k-nextcloud "3.4.2-SNAPSHOT" +(defproject org.domaindrivenarchitecture/c4k-nextcloud "4.0.0-SNAPSHOT" :description "nextcloud c4k-installation package" :url "https://domaindrivenarchitecture.org" :license {:name "Apache License, Version 2.0" :url "https://www.apache.org/licenses/LICENSE-2.0.html"} :dependencies [[org.clojure/clojure "1.10.3"] [org.clojure/tools.reader "1.3.6"] - [org.domaindrivenarchitecture/c4k-common-clj "1.1.0"]] + [org.domaindrivenarchitecture/c4k-common-clj "2.0.0"]] :target-path "target/%s/" :source-paths ["src/main/cljc" "src/main/clj"] diff --git a/src/main/clj/dda/c4k_nextcloud/uberjar.clj b/src/main/clj/dda/c4k_nextcloud/uberjar.clj index 16e6a3b..97b9321 100644 --- a/src/main/clj/dda/c4k_nextcloud/uberjar.clj +++ b/src/main/clj/dda/c4k_nextcloud/uberjar.clj @@ -5,6 +5,7 @@ [clojure.string :as cs] [clojure.tools.reader.edn :as edn] [expound.alpha :as expound] + [dda.c4k-common.yaml :as yaml] [dda.c4k-nextcloud.core :as core] [dda.c4k-nextcloud.nextcloud :as nextcloud])) @@ -42,16 +43,18 @@ :default (let [config-str (slurp config) auth-str (slurp auth) - config-edn (edn/read-string config-str) - auth-edn (edn/read-string auth-str) - config-valid? (s/valid? nextcloud/config? config-edn) - auth-valid? (s/valid? core/auth? auth-edn)] + config-parse-fn (if (yaml/is-yaml? config) yaml/from-string edn/read-string) + auth-parse-fn (if (yaml/is-yaml? auth) yaml/from-string edn/read-string) + parsed-config (config-parse-fn config-str) + parsed-auth (auth-parse-fn auth-str) + config-valid? (s/valid? nextcloud/config? parsed-config) + auth-valid? (s/valid? core/auth? parsed-auth)] (if (and config-valid? auth-valid?) - (println (core/generate config-edn auth-edn)) + (println (core/generate parsed-config parsed-auth)) (do (when (not config-valid?) (println - (expound/expound-str nextcloud/config? config-edn {:print-specs? false}))) + (expound/expound-str nextcloud/config? parsed-config {:print-specs? false}))) (when (not auth-valid?) (println - (expound/expound-str core/auth? auth-edn {:print-specs? false}))))))))))) + (expound/expound-str core/auth? parsed-auth {:print-specs? false}))))))))))) diff --git a/src/main/cljc/dda/c4k_nextcloud/core.cljc b/src/main/cljc/dda/c4k_nextcloud/core.cljc index 20b57e2..928c879 100644 --- a/src/main/cljc/dda/c4k_nextcloud/core.cljc +++ b/src/main/cljc/dda/c4k_nextcloud/core.cljc @@ -9,7 +9,7 @@ [dda.c4k-nextcloud.nextcloud :as nextcloud] [dda.c4k-nextcloud.backup :as backup])) -(def config-defaults {:issuer :staging}) +(def config-defaults {:issuer "staging"}) (def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password ::nextcloud/nextcloud-admin-user ::nextcloud/nextcloud-admin-password diff --git a/src/main/cljc/dda/c4k_nextcloud/nextcloud.cljc b/src/main/cljc/dda/c4k_nextcloud/nextcloud.cljc index ac3db50..651ef23 100644 --- a/src/main/cljc/dda/c4k_nextcloud/nextcloud.cljc +++ b/src/main/cljc/dda/c4k_nextcloud/nextcloud.cljc @@ -38,7 +38,7 @@ (defn generate-certificate [config] (let [{:keys [fqdn issuer]} config - letsencrypt-issuer (name issuer)] + letsencrypt-issuer issuer] (-> (yaml/from-string (yaml/load-resource "nextcloud/certificate.yaml")) (assoc-in [:spec :commonName] fqdn) @@ -52,8 +52,8 @@ (defn generate-ingress [config] (let [{:keys [fqdn issuer] - :or {issuer :staging}} config - letsencrypt-issuer (name issuer)] + :or {issuer "staging"}} config + letsencrypt-issuer issuer] (-> (yaml/from-string (yaml/load-resource "nextcloud/ingress.yaml")) (assoc-in [:metadata :annotations :cert-manager.io/cluster-issuer] letsencrypt-issuer) diff --git a/src/test/cljc/dda/c4k_nextcloud/core_test.cljc b/src/test/cljc/dda/c4k_nextcloud/core_test.cljc index f46cfe6..82cfcf5 100644 --- a/src/test/cljc/dda/c4k_nextcloud/core_test.cljc +++ b/src/test/cljc/dda/c4k_nextcloud/core_test.cljc @@ -13,7 +13,7 @@ :postgres-db-password "nextcloud-db-password" :nextcloud-admin-user "cloudadmin" :nextcloud-admin-password "cloudpassword" - :issuer :prod + :issuer "prod" :nextcloud-data-volume-path "/var/nextcloud" :postgres-data-volume-path "/var/postgres" :aws-access-key-id "aws-id" @@ -26,7 +26,7 @@ :postgres-db-password "nextcloud-db-password" :nextcloud-admin-user "cloudadmin" :nextcloud-admin-password "cloudpassword" - :issuer :prod + :issuer "prod" :aws-access-key-id "aws-id" :aws-secret-access-key "aws-secret" :restic-password "restic-pw" @@ -37,7 +37,7 @@ :postgres-db-password "nextcloud-db-password" :nextcloud-admin-user "cloudadmin" :nextcloud-admin-password "cloudpassword" - :issuer :prod + :issuer "prod" :aws-access-key-id "aws-id" :aws-secret-access-key "aws-secret" :restic-password "restic-pw"})))) @@ -47,7 +47,7 @@ :postgres-db-password "nextcloud-db-password" :nextcloud-admin-user "cloudadmin" :nextcloud-admin-password "cloudpassword" - :issuer :prod + :issuer "prod" :aws-access-key-id "aws-id" :aws-secret-access-key "aws-secret" :restic-password "restic-pw"}) @@ -59,7 +59,7 @@ :postgres-db-password "nextcloud-db-password" :nextcloud-admin-user "cloudadmin" :nextcloud-admin-password "cloudpassword" - :issuer :prod + :issuer "prod" :aws-access-key-id "aws-id" :aws-secret-access-key "aws-secret" :restic-password "restic-pw"}) diff --git a/src/test/cljc/dda/c4k_nextcloud/nextcloud_test.cljc b/src/test/cljc/dda/c4k_nextcloud/nextcloud_test.cljc index 024a0c6..3a2b6b6 100644 --- a/src/test/cljc/dda/c4k_nextcloud/nextcloud_test.cljc +++ b/src/test/cljc/dda/c4k_nextcloud/nextcloud_test.cljc @@ -25,7 +25,7 @@ :dnsNames ["xx"] :issuerRef {:name "prod", :kind "ClusterIssuer"}}} - (cut/generate-certificate {:fqdn "xx" :issuer :prod})))) + (cut/generate-certificate {:fqdn "xx" :issuer "prod"})))) (deftest should-generate-ingress (is (= {:apiVersion "networking.k8s.io/v1" diff --git a/valid-auth.yaml b/valid-auth.yaml new file mode 100644 index 0000000..247409a --- /dev/null +++ b/valid-auth.yaml @@ -0,0 +1,7 @@ +postgres-db-user: "nextcloud" +postgres-db-password: "nextcloud-db-password" +nextcloud-admin-user: "cloudadmin" +nextcloud-admin-password: "cloudpassword" +aws-access-key-id: "aws-id" +aws-secret-access-key: "aws-secret" +restic-password: "restic-password" \ No newline at end of file diff --git a/valid-config.edn b/valid-config.edn index 87ebb80..b50ced9 100644 --- a/valid-config.edn +++ b/valid-config.edn @@ -1,5 +1,5 @@ {:fqdn "cloud.test.meissa-gmbh.de" - :issuer :staging + :issuer "staging" :nextcloud-data-volume-path "/var/cloud" :postgres-data-volume-path "/var/postgres" :restic-repository "s3:s3.amazonaws.com/your-bucket/your-folder"} \ No newline at end of file diff --git a/valid-config.yaml b/valid-config.yaml new file mode 100644 index 0000000..c716cf2 --- /dev/null +++ b/valid-config.yaml @@ -0,0 +1,5 @@ +fqdn: "cloud.test.meissa-gmbh.de" +issuer: "staging" +nextcloud-data-volume-path: "/var/cloud" +postgres-data-volume-path: "/var/postgres" +restic-repository: "s3:s3.amazonaws.com/your-bucket/your-folder" \ No newline at end of file