vert-x3 / vertx-config

Vert.x Configuration Service
Apache License 2.0
54 stars 64 forks source link

Overloading rules - shallow json merge #21

Closed marcinczeczko closed 7 years ago

marcinczeczko commented 7 years ago

Is there a reason why config retriever merges config JSONs only at depth 1 ? I have following case where config files is pretty big, so wanted to split it into smaller fragments, and let config retriever to merge it into on. In order to simplify management of configuration of my app, I wanted to split config files into two. For instance, first config file have:

{
   "a": {
       "b": {
           "foo": "bar"
       }
   }
}

In the second one, I wanted to configure other fields under a.b as follows (so keep "c" configurations in a separate file)

{
   "a": {
       "c": {
           "foo": "bar"
       }
   }
}

I configure retriever to get those two files (two file stores) and expected to get

{
   "a": {
       "b": {
           "foo": "bar"
       },
       "c": {
           "foo": "bar"
       }
   }
}

But the resulting configuration is the one from the second file. It simply overwrote the object "a" because the retriever does json.mergeIn(JsonObject) so it merges only on the level of "a" object. Why it cannot do deep merge ? json.mergeIn(JsonObject, true) ?

cescoffier commented 7 years ago

I believe it has already been fixed: https://github.com/vert-x3/vertx-config/commit/1d33cf9242e3e813d70969f6d510a7291a738d19#diff-068b3a4e126c877ee327bca32d49fdc8

marcinczeczko commented 7 years ago

I didn't notice I was still using 3.4.1 that had that issue.

Thanks