add ability to either consume yaml or edn

This commit is contained in:
jerger 2022-12-28 08:40:08 +01:00
parent b42b8a0bb8
commit a85e3c3b24
4 changed files with 8 additions and 5 deletions

View file

@ -2,7 +2,7 @@
"name": "c4k-common-cljs", "name": "c4k-common-cljs",
"description": "Contains predicates and tools for c4k", "description": "Contains predicates and tools for c4k",
"author": "meissa GmbH", "author": "meissa GmbH",
"version": "4.0.1-SNAPSHOT", "version": "4.1.0-SNAPSHOT",
"homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-common#readme", "homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-common#readme",
"repository": "https://www.npmjs.com/package/c4k-common", "repository": "https://www.npmjs.com/package/c4k-common",
"license": "APACHE2", "license": "APACHE2",

View file

@ -1,4 +1,4 @@
(defproject org.domaindrivenarchitecture/c4k-common-cljs "4.0.1-SNAPSHOT" (defproject org.domaindrivenarchitecture/c4k-common-cljs "4.1.0-SNAPSHOT"
:description "Contains predicates and tools for c4k" :description "Contains predicates and tools for c4k"
:url "https://domaindrivenarchitecture.org" :url "https://domaindrivenarchitecture.org"
:license {:name "Apache License, Version 2.0" :license {:name "Apache License, Version 2.0"

View file

@ -1,4 +1,4 @@
(defproject org.domaindrivenarchitecture/c4k-common-clj "4.0.1-SNAPSHOT" (defproject org.domaindrivenarchitecture/c4k-common-clj "4.1.0-SNAPSHOT"
:description "Contains predicates and tools for c4k" :description "Contains predicates and tools for c4k"
:url "https://domaindrivenarchitecture.org" :url "https://domaindrivenarchitecture.org"
:license {:name "Apache License, Version 2.0" :license {:name "Apache License, Version 2.0"

View file

@ -4,6 +4,7 @@
[clojure.spec.alpha :as s] [clojure.spec.alpha :as s]
[clojure.string :as cs] [clojure.string :as cs]
[clojure.tools.reader.edn :as edn] [clojure.tools.reader.edn :as edn]
[dda.c4k-common.yaml :as yaml]
[dda.c4k-common.common :as cm] [dda.c4k-common.common :as cm]
[dda.c4k-common.core :as core] [dda.c4k-common.core :as core]
[expound.alpha :as expound])) [expound.alpha :as expound]))
@ -39,8 +40,10 @@
:else :else
(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-edn (config-parse-fn config-str)
auth-edn (auth-parse-fn auth-str)
config-valid? (s/valid? config-spec? config-edn) config-valid? (s/valid? config-spec? config-edn)
auth-valid? (s/valid? auth-spec? auth-edn)] auth-valid? (s/valid? auth-spec? auth-edn)]
(if (and config-valid? auth-valid?) (if (and config-valid? auth-valid?)