I'm setting up config map using environ for fetching up env variables. Since environ normalizes upper case to lowercase and "_" characters to "-", I ended up with repetitions of keywords
(def config {:consumer-key (env :consumer-key)
:keystore-password (env :consumer-key)
:ssl-keystore-password (env :ssl-keystore-password)
:ssl-certificate-name (env :ssl-certificate-name)
:callback-url (env :callback-url)
:mp-private-key (env :mp-private-key)
:merchant-checkout-id (env :merchant-checkout-id)
:is-sandbox (env :is-sandbox)})
is there a way to prevent this repetition? maybe a function which receives a keyword and returns some kind of key value pair for the map?
As mentioned in the comments, since
env
is a map you can just useselect-keys
with a list of keys to copy:Alan Thompson's approach is reasonable if you have an arbitrary function rather than specifically a map.