mirror of
https://github.com/journeyman-cc/smeagol.git
synced 2026-04-12 18:05:06 +00:00
Work on configuration
This commit is contained in:
parent
ad18d2eb1e
commit
9f66ccf6ab
3 changed files with 4 additions and 38 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -20,6 +20,7 @@ smeagol.log*
|
|||
.calva/
|
||||
.idea/
|
||||
.lsp/
|
||||
.clj-kondo/
|
||||
|
||||
resources/public/content/uploads/
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
:url "https://github.com/simon-brooke/smeagol"
|
||||
:license {:name "GNU General Public License,version 2.0 or (at your option) any later version"
|
||||
:url "https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html"}
|
||||
:dependencies [[clj-jgit "1.0.0"]
|
||||
:dependencies [[clj-jgit "0.8.10"]
|
||||
[clj-yaml "0.4.0"]
|
||||
[clojure.java-time "0.3.2"]
|
||||
[com.cemerick/url "0.1.1"]
|
||||
|
|
@ -55,7 +55,7 @@
|
|||
[lein-ring "0.12.5" :exclusions [org.clojure/clojure]]]
|
||||
|
||||
:npm {:dependencies [[simplemde "1.11.2"]
|
||||
[vega "5.8.0"]
|
||||
[vega "5.9.0"]
|
||||
[vega-embed "6.2.2"]
|
||||
[vega-lite "4.1.1"]
|
||||
[mermaid "8.4.6"]
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
(defn- from-env-vars
|
||||
"Read a map from those of these environment `vars` which have values"
|
||||
[vars]
|
||||
(log/info (str "env is: " (keys env)))
|
||||
(reduce
|
||||
#(let [v (env %2)]
|
||||
(if v
|
||||
|
|
@ -57,42 +58,6 @@
|
|||
vars))
|
||||
|
||||
|
||||
;;; TODO: OK, why this doesn't work. We need a namespace (and, indeed, ideally
|
||||
;;; in a library) which returns the name/value pairs of the InitialContext as
|
||||
;;; a map. We need this because, if the config file itself is to be specified
|
||||
;;; in this way, we need to be able to access this map BEFORE we do build-config.
|
||||
(defn- from-initial-context
|
||||
"Config `vars` are read from the initial context, which (at least under Tomcat)
|
||||
are specific to the individual web app. Nevertheless the same names will
|
||||
be used as for environment variables, because it just makes life easier."
|
||||
[vars]
|
||||
(log/info "Seeking config in initial context")
|
||||
(log/debug (str "Bound names are: " (map #(.toString %) (.list (new javax.naming.InitialContext) "java:comp/env/"))))
|
||||
(try
|
||||
(reduce
|
||||
#(try
|
||||
(log/debug "Seeking value for " %2 " in initial context")
|
||||
(let [v (javax.naming.InitialContext/doLookup %2)]
|
||||
(if v
|
||||
(do
|
||||
(log/info (str "Read value of " %2 " from initial context as " v))
|
||||
(assoc %1 %2 v))
|
||||
%1))
|
||||
(catch Exception e
|
||||
(log/debug (str "Error while seeking value for " %2 " in initial context: " (type e) "; " (.getMessage e)))
|
||||
%1))
|
||||
{}
|
||||
(map #(str
|
||||
"java:comp/env/"
|
||||
(s/replace (name %) #"-" "_")) vars))
|
||||
(catch javax.naming.NoInitialContextException _
|
||||
;; ignore: this only means we're not in a servlet context,
|
||||
;; e.g unit tests.
|
||||
)
|
||||
(catch Exception other
|
||||
(log/warn (str "Error while seeking values in initial context: " (type other) "; " (.getMessage other))))))
|
||||
|
||||
|
||||
(defn to-keyword
|
||||
"Convert this argument into an idiomatic clojure keyword."
|
||||
[arg]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue