m3rger is a tool for merging up to 3 layers of YAML configuration files.
$ ./m3rger-darwin --help
usage: m3rger-darwin [<flags>] <default> [<low>] [<high>]
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
-o, --out=OUT Write the output to a file (by default m3rger prints to stdout)
--version Show application version.
Args:
<default> A YAML file with default values that may be overridden
[<low>] A YAML file that will override any values in 'default', but not any in the 'high' file
[<high>] A YAML file whose keys will override anything from 'low' or 'default'm3rger merges up to three files.
default: A YAML file with default/generic values. If no other files are provideddefaultis returned as is.low: Scalar values and arrays in this file will overwrite those ofdefaultwhenever there is a collision. Maps are merged.high: Scalar values and arrays in this file will overwrite those oflowand/ordefaultwhenever there is a collision. Maps are merged.
The only trick with running m3rger in a container is remembering that the
files to be merged have to exist inside the container for m3rger to be
able to read them. The easiest way to do that is using --volume to mount
the directory the files are in:
$ ls
default.yml high.yml low.yml
$ docker run --rm --read-only --volume=$(pwd):/input:ro \
benjdewan/m3rger /input/default.yml /input/low.yml /input/high.yml
foo: mumble
key: val
map:
baz: quux
key: valdefault.yml
foo: bar
map:
key: val
baz: qux$ ./m3rger ./default.yml
foo: bar
map:
key: val
baz: quxdefault.yml
foo: bar
map:
key: val
baz: quxoverride.yml
mumble: foobar$ ./m3rger ./default.yml ./override.yml
foo: bar
map:
key: val
baz: qux
mumble: foobardefault.yml
foo: bar
map:
key: val
baz: quxoverride.yml
foo: mumble$ ./m3rger ./default.yml ./override.yml
foo: mumble
map:
key: val
baz: quxdefault.yml
foo: bar
map:
key: val
baz: quxoverride.yml
map:
key: mumble
foo: bar$ ./m3rger ./default.yml ./override.yml
foo: bar
map:
key: mumble
baz: qux
foo: bardefault.yml
foo: bar
map:
key: val
baz: quxlow.yml
foo: baz
key: val
map:
baz: zabhigh.yml
foo: mumble
map:
baz: quux$ ./m3rger ./default.yml ./low.yml ./high.yml
foo: mumble
key: val
map:
baz: quux
key: val