mount

richiardiandrea 2016-08-09T18:56:31.000476Z

A question about cprop, I am reading: https://github.com/tolitius/cprop#merging-configurations

richiardiandrea 2016-08-09T18:56:50.000478Z

and I gather that the :merge clause is merged after

richiardiandrea 2016-08-09T18:57:17.000479Z

am I correct in saying that this part is therefore not overridable by system props/env vars?

richiardiandrea 2016-08-09T18:57:45.000480Z

ok no

richiardiandrea 2016-08-09T18:57:51.000481Z

it is not correct lol

richiardiandrea 2016-08-09T18:58:14.000482Z

it is not overridable by conf and classpath resource file

tolitius 2016-08-09T18:58:35.000483Z

if I understand correctly what the question is 🙂 you can set the order in :merge

richiardiandrea 2016-08-09T18:58:59.000484Z

no I had a bug yesterday but it is more a bug in my head 😄

tolitius 2016-08-09T18:59:07.000485Z

you can do crazy things like:

(load-config :resource "path/within/classpath/to.edn"
             :file "/path/to/some.edn"
             :merge [{:datomic {:url "foo.bar"}} 
                     (from-file "/path/to/another.edn")
                     (from-resource "path/within/classpath/to-another.edn")
                     (parse-runtime-args ...)
                     (from-system-props)
                     (from-env)])

richiardiandrea 2016-08-09T18:59:23.000486Z

so I have a conf file

tolitius 2016-08-09T18:59:26.000487Z

but in most cases you don't have to

richiardiandrea 2016-08-09T18:59:37.000488Z

then I do:

(c/load-config :merge [env/defaults
                         {:version (if-let [version (version!)] version "0.0.0")}])

tolitius 2016-08-09T18:59:38.000489Z

ok, conf is an edn file?

richiardiandrea 2016-08-09T18:59:42.000490Z

yes

richiardiandrea 2016-08-09T19:00:05.000491Z

so I expected that my conf file could override the stuff in env/defaults

tolitius 2016-08-09T19:00:16.000493Z

env/defaults returns you a map with overriding paths?

richiardiandrea 2016-08-09T19:00:20.000494Z

yeah

richiardiandrea 2016-08-09T19:00:25.000495Z

every prop matches

richiardiandrea 2016-08-09T19:00:39.000496Z

but conf takes precedence on the :merge clause right?

tolitius 2016-08-09T19:01:02.000497Z

hm.. not really, here is the order:

1. classpath resource config
2. file on a file system (pointed by a conf system property or by (load-config :file <path>))
3. custom configurations, maps from various sources, etc.
4. System properties
5. ENV variables

richiardiandrea 2016-08-09T19:01:06.000498Z

yeah 😄

richiardiandrea 2016-08-09T19:01:25.000500Z

that's why I was saying...read the docs Andrea!

tolitius 2016-08-09T19:02:02.000501Z

that's ok, I don't expect people to read it, it just there for my reference to answer questions quickly 🙂

richiardiandrea 2016-08-09T19:02:06.000502Z

the README is consistent

richiardiandrea 2016-08-09T19:02:07.000503Z

lol

richiardiandrea 2016-08-09T19:02:11.000504Z

good point

tolitius 2016-08-09T19:02:52.000505Z

if you still want to override the defaults, you can add a element to the :merge map

tolitius 2016-08-09T19:03:11.000506Z

the way I usually do it is to have a file in a classpath, say config.edn

richiardiandrea 2016-08-09T19:03:14.000507Z

yeah now it is super clear

richiardiandrea 2016-08-09T19:03:37.000508Z

I will do this:

(defn make-config
  "Creates a default configuration map"
  []
  (merge env/defaults
         (c/load-config :merge [{:version (if-let [version (version!)] version "0.0.0")}])))

tolitius 2016-08-09T19:04:10.000509Z

then I would have a (say) dev overrides somewhere under dev-resources/dev-overrides.edn, and then I start things with -Dconf=dev-resources/dev-overrides.edn

tolitius 2016-08-09T19:04:38.000510Z

then I can just do (load-config)

tolitius 2016-08-09T19:04:52.000511Z

but there are many ways to do it of course

richiardiandrea 2016-08-09T19:04:55.000512Z

yes, the thing is, I already have that

richiardiandrea 2016-08-09T19:05:04.000513Z

I wanted an external file

richiardiandrea 2016-08-09T19:05:09.000514Z

per-server

richiardiandrea 2016-08-09T19:05:22.000515Z

and conf it is very convenient

tolitius 2016-08-09T19:05:28.000516Z

where would the file live?

richiardiandrea 2016-08-09T19:05:33.000517Z

on the server

tolitius 2016-08-09T19:05:35.000518Z

somewhere on that server

tolitius 2016-08-09T19:06:33.000519Z

right, so you can just have config.edn in your classpath (which would be read by default), and just use -Dconf=server-path-to/overrides.edn

richiardiandrea 2016-08-09T19:07:06.000520Z

yep, the env/defaults thing is a namespace a-la-Luminus for codeful conf

richiardiandrea 2016-08-09T19:07:28.000521Z

so it makes sense to merge it first (no priority)

tolitius 2016-08-09T19:07:31.000522Z

I usually have things that I always want to override as:

:server {:application {:version "OVERRIDE ME"}
        :http {:port "OVERRIDE ME"
               :max-channel-memory-size 0
               :max-total-memory-size 0
               :http {:request {:max-chunk-size 8192
   ...

richiardiandrea 2016-08-09T19:07:51.000523Z

yeah I keep those there but empty

tolitius 2016-08-09T19:08:13.000524Z

and then

:server {:application {:version "1.0"}
          :http {:port "4242"}}
in override.edn

richiardiandrea 2016-08-09T19:08:33.000527Z

great yes I am doing the same

tolitius 2016-08-09T19:08:35.000528Z

or via ENV

richiardiandrea 2016-08-09T19:08:51.000529Z

the file is convenient because I can just copy the one in resources

tolitius 2016-08-09T19:08:54.000530Z

SERVER__APPLICATION__VERSION=1.0

richiardiandrea 2016-08-09T19:09:02.000531Z

and launch java with -Dconf=....

tolitius 2016-08-09T19:09:11.000533Z

right, whatever works 🙂

richiardiandrea 2016-08-09T19:09:30.000535Z

ah ah, the important is to have the choice and cprop gives you plenty

tolitius 2016-08-09T19:11:22.000540Z

yea, I am actually experimenting with Vault ( https://github.com/tolitius/gblog ), and going through my thinking phase on having a cprop extension to it

tolitius 2016-08-09T19:12:01.000542Z

since ENV and plain files are not really that good for secrets

richiardiandrea 2016-08-09T19:12:25.000543Z

oh that's a wonderful tool did not know it (I mean Ghost)!

richiardiandrea 2016-08-09T19:13:08.000544Z

yeah encrypted stuff would be great to integrate in cprop, but at least one piece of info has to be clear text on the server I guess

tolitius 2016-08-09T19:13:20.000545Z

not really 🙂

tolitius 2016-08-09T19:13:38.000546Z

it could be a temp token, that would only work for you and only one time and only for the next 5 seconds

tolitius 2016-08-09T19:14:00.000547Z

to fetch creds to the runtime

tolitius 2016-08-09T19:14:52.000548Z

i.e. you would run things like:

export ACCESS_TOKEN=$(./tools/vault/wrap-token.sh /secret/postgres); docker-compose up

richiardiandrea 2016-08-09T19:15:15.000549Z

cool stuff

tolitius 2016-08-09T19:15:20.000550Z

where Vault would wrap the location into a token, which you can set a ttl on

tolitius 2016-08-09T19:15:32.000551Z

it would only work for /secret/postgres, and only once

richiardiandrea 2016-08-09T19:16:10.000552Z

and encrypting of the info is done with a master key before that (sorry dunno how vault works)

richiardiandrea 2016-08-09T19:16:53.000553Z

I guess is basically some sort of bitcoin seeded wallet

tolitius 2016-08-09T19:18:19.000554Z

right, when you install Vault you get a root token. you don't have to give it out to others, but you can use it to store secrets in Vault. you also can create a token for someone else to store creds to Vault (no need to use the root token). once creds are set / stored, all the apps that need these creds would only need a temp token

richiardiandrea 2016-08-09T19:18:42.000555Z

nice

tolitius 2016-08-09T19:18:47.000556Z

yea, pretty cool

richiardiandrea 2016-08-09T19:19:39.000557Z

it is kind of similar to bitcoin really, as long as you don't lose your master key, you can always generate tokens/public keys to decrypt

richiardiandrea 2016-08-09T19:19:53.000558Z

I'll have a look

richiardiandrea 2016-08-09T19:20:01.000559Z

thanks for sharing!

tolitius 2016-08-09T19:22:04.000560Z

sure, always welcome

👍 1