Version: 1.1
Extending Configs
Β
A common pattern is to extend an existing config, overriding and/or adding new config values to it. The extension is done by including the base configuration, and then overriding the chosen values in the current config.
info
This page assumes that you are familiar with the contents of The Defaults List.
Extending a config from the same config group:β
config.yaml
defaults:
- db: mysql
db/mysql.yaml
defaults:
- base_mysql
user: omry
password: secret
port: 3307
encoding: utf8
db/base_mysql.yaml
host: localhost
port: 3306
user: ???
password: ???
Output:
$ python my_app.py
db:
host: localhost # from db/base_mysql
port: 3307 # overriden by db/mysql.yaml
user: omry # populated by db/mysql.yaml
password: secret # populated by db/mysql.yaml
encoding: utf8 # added by db/mysql.yaml
Extending a config from another config group:β
To extend a config from a different config group, include it using an absolute path (/), and override the package to _here_. (_here_ is described in Packages)
db/mysql.yaml
defaults:
- /db_schema/base_mysql@_here_
It is otherwise identical to extending a config within the same config group.