This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-05
Channels
- # aws (6)
- # beginners (10)
- # boot (33)
- # cider (23)
- # cljs-dev (50)
- # cljsjs (2)
- # cljsrn (10)
- # clojars (1)
- # clojure (215)
- # clojure-czech (1)
- # clojure-dev (5)
- # clojure-italy (23)
- # clojure-russia (18)
- # clojure-spec (11)
- # clojure-uk (53)
- # clojurescript (157)
- # core-async (29)
- # cursive (12)
- # data-science (15)
- # datascript (16)
- # datomic (68)
- # graphql (2)
- # jobs (5)
- # jobs-discuss (1)
- # juxt (17)
- # lein-figwheel (2)
- # luminus (3)
- # off-topic (155)
- # om (3)
- # pedestal (1)
- # portkey (1)
- # re-frame (7)
- # reagent (4)
- # ring (3)
- # ring-swagger (2)
- # rum (11)
- # unrepl (11)
- # vim (1)
- # yada (2)
Anyone know the best way to set environment variables when testing when you use aero
? Usually we’ve used environ
and set environment variables in .profiles.clj
when testing. Is it best to just also include environ
?
Thanks @dominicm. That’s fine for loading the env vars but we want to be able to set some env vars for local development. Usually we’d do this with .profiles.clj
and use environ
.
Our main problem is that we want to load different configs depending on what an environment is set as (say we have region
ENV VAR). This env var can be set up using consul in our prod and pre-prod environments but I was wondering how we’d set this in our local dev environments. We also want to throw an exception if that env var is not set.
When you call into aero, you can provide the profile as a value. Your get-profile would perhaps look like this:
(defn get-profile []
(doto (keyword (System/getenv "region")) assert))
(aero/read-config (io/resource "config.edn") {:profile (get-profile)})
Then in config.edn:
{:db-url #profile {:prod ""
:dev "ddb:"}
although I might be inclined to update the example to have better boundaries. But that's another matter 🙂
:thinking_face: As long as you have a function which produces a system & takes a profile, you're golden. In your -main
function, you use the (get-profile)
function, this is what will be called in the uberjar.
In dev, you have the dev/
directory on the classpath. And when you have your start
stop
reset
going on in there, that takes care of enforcing the :dev
profile.
Let me know if you need any help 🙂