Selecting multiple configs from a Config Group
Problem
In some scenarios, one may need to select multiple configs from the same Config Group.
Solution
Use a list of config names as the value of the config group in the Defaults List or in the command line.
Example
In this example, we configure a server. The server can host multiple websites at the same time.
├── config.yaml
└── server
├── apache.yaml
└── site
├── amazon.yaml
├── fb.yaml
└── google.yaml
defaults:
- server/apache
defaults:
- site:
- fb
- google
host: localhost
port: 443
amazon:
domain: amazon.com
fb:
domain: facebook.com
google:
domain: google.com
Output:
server:
site:
fb:
domain: facebook.com
google:
domain: google.com
host: localhost
port: 443
Override the selected sites from the command line by passing a list. e.g:
server:
site:
google:
domain: google.com
amazon:
domain: amazon.com
host: localhost
port: 443
Implementation considerations
The following two forms compose the same output:
defaults:
- site:
- fb
- google
defaults:
- site/fb
- site/google
Use the nested list form when you want to override the group later with
'server/site=[...]'.
To delete one of these non-overridable entries from the command line, use the
exact config path, for example ~server/site/fb.
All default package for all the configs in server/site is server.site.
This example uses an explicit nesting level inside each of the website configs to prevent them stepping over one another:
amazon:
...