Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load-config with alternate "environment" maps? #103

Open
gonewest818 opened this issue Nov 6, 2017 · 0 comments
Open

load-config with alternate "environment" maps? #103

gonewest818 opened this issue Nov 6, 2017 · 0 comments

Comments

@gonewest818
Copy link

I'd like to propose a modification to "load-config" that optionally allows the caller to supply a function to look up the environment variables. Doing so would support use cases where the developer has adopted adzerk-oss/env or weavejester/environ or whatever is their favorite "12 factor app" style environment configuration lib.

So essentially, something like this

(defn load-config
  ([r] (load-config r System/getenv))
  ([r lookup]
   (edn/read {:readers {'env (fn [x] (lookup (str x)))
                        'envf (fn [[fmt & args]]
                                (apply format fmt
                                       (map #(lookup (str %)) args)))}}
             (PushbackReader. (io/reader r)))))

allowing the user to optionally supply the lookup as a lambda like so

(load-config r #(get (adzerk.env/env) %))

I haven't thought through the joplin.alias use case... Ideally the same "lookup" substitution would work there too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant