This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-24
Channels
- # admin-announcements (1)
- # alda (22)
- # aws-lambda (1)
- # beginners (9)
- # boot (17)
- # cider (39)
- # cljs-dev (10)
- # cljsjs (1)
- # cljsrn (14)
- # clojure (88)
- # clojure-android (1)
- # clojure-dev (9)
- # clojure-india (1)
- # clojure-russia (271)
- # clojure-spec (5)
- # clojure-uk (101)
- # clojurescript (74)
- # clojutre (11)
- # component (2)
- # cursive (24)
- # datascript (7)
- # datomic (9)
- # dirac (13)
- # docs (3)
- # emacs (4)
- # garden (21)
- # hoplon (9)
- # jobs-rus (5)
- # lein-figwheel (3)
- # leiningen (13)
- # luminus (12)
- # off-topic (1)
- # om (24)
- # onyx (84)
- # proton (3)
- # re-frame (39)
- # reagent (21)
- # rethinkdb (1)
- # slack-help (10)
- # specter (4)
- # test-check (1)
- # untangled (35)
- # yada (2)
Hey, i have a question on accessing environment variables in project.clj
and hope someone can help me out: I am writing a lein plugin, and i need to read something like {:config :env/CONFIG_A}
in project.clj
, but couldnt get it work. Looking at other projects (lein plugins) but I couldnt figure out how this works
Can you explain a bit further? I use lein-environ for env stuff, but I think it’s a bit different to what you’re wanting to do
@danielcompton basically, i have seen something like this {:user-name :env/USER_NAME}
in project.clj, and it got picked up as environment variables
That will be plugin specific I expect
but you would iterate over the kv in your config, check each value to see if it is a keyword, and if so if it's namespace is env
If so, then use (System/getEnv..
to look up the name
of the keyword
lein-environ does the opposite thing here https://github.com/weavejester/environ/blob/master/lein-environ/src/lein_environ/plugin.clj#L17
> "Keywords with a project namespace are looked up in the project map. For example:"
lein does this at https://github.com/technomancy/leiningen/blob/4a683b85eda2e0662120a12a1f0680e6ebc0c28c/leiningen-core/src/leiningen/core/user.clj#L158
but AFAICT this is specific to repositories, not a general functionality that you can use anywhere in project.clj
The philosophy of Leiningen is to lean towards repeatable builds, so generally you only want environment variables for things that shouldn’t be stored in code, e.g. passwords