I've had one too on similar lines for quite some time

https://github.com/jaju/properties-clj

Primarily used for the `properties` format, but it supports EDN too via the
`read-edn` function. This library uses the almost-BASH syntax for picking
env variables with default

${USER:some-user} would be replaced with
1. "valid-user" if System/getenv has the USER variable defined
2. "some-user" if not.

Works for both properties files and EDN, although I never bothered to put
EDN examples in the README all this while and updated it just now.

On Tue, Feb 20, 2018 at 8:29 PM, Alan Thompson <clooj...@gmail.com> wrote:

> Looks very useful.  One suggestion:  the example might be easier to read
> if you included the values of the env vars, and clarified the way you
> specify default values:
>
> {:connection-pool
>   {:user-name #dyn/prop [DB_USER "accountsuser"]  ; default value
> "accountsuser"
>    :user-pw #dyn/prop DB_PW                       ; no default value
>    :url  #dyn/join ["jdbc:postgresql://"
>                        #dyn/prop [DB_HOST "localhost"]
>                        ":"
>                        #dyn/prop [DB_PORT "5432"]
>                        "/accounts"]}
>  :web-server
>   {:port #dyn/long #dyn/prop "WEB_PORT"}}
>
>
> with  environment variables:
>
> # DB_USER <undefined>
> DB_PW=change-me
> DB_HOST=db.example.org
> # DB_PORT <undefined>
> WEB_PORT=8192
>
>
> yields:
>
> {:connection-pool
>   {:user-name "accountsuser"
>    :user-pw "change-me"
>    :url  "jdbc:postgresql://db.example.org:5432/accounts"]}
>  :web-server
>   {:port 8192}}
>
>
>
>
>
>
> On Fri, Feb 16, 2018 at 2:20 PM, Howard Lewis Ship <hls...@gmail.com>
> wrote:
>
>>
>> com.walmartlabs/dyn-edn 0.1.0
>>
>> Tiny library to allow dynamic data when parsing EDN; useful for
>> configuration files.
>>
>> https://github.com/hlship/dyn-edn
>>
>> For example:
>>
>> {:connection-pool
>>   {:user-name #dyn/prop [DB_USER "accountsuser"]
>>    :user-pw #dyn/prop DB_PW
>>    :url  #dyn/join ["jdbc:postgresql://"
>>                        #dyn/prop [DB_HOST "localhost"]
>>                        ":"
>>                        #dyn/prop [DB_PORT "5432"]
>>                        "/accounts"]}
>>  :web-server
>>   {:port #dyn/long #dyn/prop "WEB_PORT"}}
>>
>>
>> can use environment variables to reduce down to:
>>
>>
>> {:connection-pool
>>   {:user-name "accountsuser"
>>    :user-pw "change-me"
>>    :url  "jdbc:postgresql://db.example.org:5432/accounts"]}
>>  :web-server
>>   {:port 8192}}
>>
>>
>> --
>> Howard M. Lewis Ship
>>
>> Senior Mobile Developer at Walmart Labs
>>
>> Creator of Apache Tapestry
>>
>> (971) 678-5210
>> http://howardlewisship.com
>> @hlship
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to