Skip to main content
Version: 1.1

Extending Configs

 Example

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: omrypassword: secretport: 3307encoding: utf8
db/base_mysql.yaml
host: localhostport: 3306user: ???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/[email protected]_here_

It is otherwise identical to extending a config within the same config group.