Easy clojure environment variables
Given an .env file in the root of your project directory:
A_VALUE=hello(ns your-project
(:require [env.core :as env]))
(env/env :a-value) ; => helloAdd this to your deps.edn
coast-framework/env {:mvn/version "1.0.3"}}Given a .env file above or the equivalent env.edn
Notice system environment variables and values in .env are all upper and snake case, while the env.edn variables are all lower, kebab case keywords.
{:a-value "hello"}This will return "hello"
(env/env :a-value)env.edn has one trick up it's sleeve, tagged literals. You can set a #env tagged literal to grab a value from the actual environment and commit env.edn without committing the secret to source control.
env.edn (committed to source control)
{:a-secret-value #env :session-key}.env (not committed to source control)
SESSION_KEY=123456
COAST_ENV=dev(env/env :a-secret-value) ; => "123456"cd env && make test