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"}
|
||||
: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 "1.1.1-SNAPSHOT"]]
|
||||
:target-path "target/%s/"
|
||||
:source-paths ["src/main/cljc"
|
||||
"src/main/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})))))))))))
|
||||
|
|
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