Added yaml config reader
This commit is contained in:
parent
34a3ca4728
commit
775689b348
4 changed files with 23 additions and 8 deletions
|
@ -5,7 +5,7 @@
|
||||||
:url "https://www.apache.org/licenses/LICENSE-2.0.html"}
|
:url "https://www.apache.org/licenses/LICENSE-2.0.html"}
|
||||||
:dependencies [[org.clojure/clojure "1.10.3"]
|
:dependencies [[org.clojure/clojure "1.10.3"]
|
||||||
[org.clojure/tools.reader "1.3.6"]
|
[org.clojure/tools.reader "1.3.6"]
|
||||||
[org.domaindrivenarchitecture/c4k-common-clj "1.1.0"]]
|
[org.domaindrivenarchitecture/c4k-common-clj "1.1.1-SNAPSHOT"]]
|
||||||
:target-path "target/%s/"
|
:target-path "target/%s/"
|
||||||
:source-paths ["src/main/cljc"
|
:source-paths ["src/main/cljc"
|
||||||
"src/main/clj"]
|
"src/main/clj"]
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
[clojure.string :as cs]
|
[clojure.string :as cs]
|
||||||
[clojure.tools.reader.edn :as edn]
|
[clojure.tools.reader.edn :as edn]
|
||||||
[expound.alpha :as expound]
|
[expound.alpha :as expound]
|
||||||
|
[dda.c4k-common.yaml :as yaml]
|
||||||
[dda.c4k-nextcloud.core :as core]
|
[dda.c4k-nextcloud.core :as core]
|
||||||
[dda.c4k-nextcloud.nextcloud :as nextcloud]))
|
[dda.c4k-nextcloud.nextcloud :as nextcloud]))
|
||||||
|
|
||||||
|
@ -42,16 +43,18 @@
|
||||||
:default
|
:default
|
||||||
(let [config-str (slurp config)
|
(let [config-str (slurp config)
|
||||||
auth-str (slurp auth)
|
auth-str (slurp auth)
|
||||||
config-edn (edn/read-string config-str)
|
config-parse-fn (if (yaml/is-yaml? config) yaml/from-string edn/read-string)
|
||||||
auth-edn (edn/read-string auth-str)
|
auth-parse-fn (if (yaml/is-yaml? auth) yaml/from-string edn/read-string)
|
||||||
config-valid? (s/valid? nextcloud/config? config-edn)
|
parsed-config (config-parse-fn config-str)
|
||||||
auth-valid? (s/valid? core/auth? auth-edn)]
|
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?)
|
(if (and config-valid? auth-valid?)
|
||||||
(println (core/generate config-edn auth-edn))
|
(println (core/generate parsed-config parsed-auth))
|
||||||
(do
|
(do
|
||||||
(when (not config-valid?)
|
(when (not config-valid?)
|
||||||
(println
|
(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?)
|
(when (not auth-valid?)
|
||||||
(println
|
(println
|
||||||
(expound/expound-str core/auth? auth-edn {:print-specs? false})))))))))))
|
(expound/expound-str core/auth? parsed-auth {:print-specs? false})))))))))))
|
||||||
|
|
7
valid-auth.yaml
Normal file
7
valid-auth.yaml
Normal file
|
@ -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"
|
5
valid-config.yaml
Normal file
5
valid-config.yaml
Normal file
|
@ -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"
|
Loading…
Reference in a new issue