-
Notifications
You must be signed in to change notification settings - Fork 0
Config schema files
In order to support needed operations like merging on key collisions, you cannot provide Ranvier with your raw config file. Ranvier requires a specific (yet simple) JSON format. For example, let's say we have config for our user's service that we'll store in users.json
{
"extends": [
"staging.json"
],
"config": {
"db": {
"hostname": "pg.mycompany.com",
"port": 5432
}
}
}
There are two fields that are most relevant here, extends
and config
. These are the minimum required fields for a valid Ranvier config schema. This tells Ranvier that you have a config file with the name users
and it stores DB connection info. It also tells Ranvier that the base of this JSON file should be the staging.json
file.
The extends
field allows you to keep common config values stored in one place e.g. environment-wide config. Any file which extends
another will contain the values of the config
field as well as its own. In the case of a key collision between the files, the "inheritor" (or users.json
in this case), will take precedence. Extends
contains a list of string filepaths which are relative to the root of your Git repo. Meaning if you have a Git repo that looks like
├── users.json
└── env
├── staging.json
└── prod.json
And you wanted to extend env/staging.json
in users.json
the schema file would look like
{
"extends": [
"env/staging.json"
],
"config": {
...
}
}
And now users.json
will store all of the config listed in the config
field as well as all of the config listed in env.staging.json
.
For more detailed info, see the model itself.