configuration: finish 2.2.0, update readme
This commit is contained in:
parent
8738154537
commit
76fe71a474
4 changed files with 19 additions and 4 deletions
|
@ -38,9 +38,17 @@ You can also load configuration from the environment:
|
|||
system_path: $PATH
|
||||
```
|
||||
|
||||
If a `.env` file is present in your configuration directory, then it will be loaded before
|
||||
If a `.env` file is present in your configuration directory (i.e. `config/.env`), then it will be loaded before
|
||||
applying YAML configuration.
|
||||
|
||||
You can also include values from one file into another:
|
||||
```yaml
|
||||
_include:
|
||||
- "./include-prod.yaml"
|
||||
- "./include-misc.yaml"
|
||||
_include: "just-one-file.yaml"
|
||||
```
|
||||
|
||||
**Server-side**
|
||||
Call `configuration()`. The loaded configuration will be available in your application's
|
||||
`configuration` map.
|
||||
|
@ -71,4 +79,4 @@ foo:
|
|||
bar: baz
|
||||
quux: goodbye
|
||||
yellow: submarine
|
||||
```
|
||||
```
|
||||
|
|
|
@ -21,7 +21,7 @@ Future<void> _loadYamlFile(Map map, File yamlFile, Map<String, String> env,
|
|||
|
||||
var out = {};
|
||||
|
||||
var configMap = config as Map;
|
||||
var configMap = Map.of(config as Map);
|
||||
|
||||
// Check for _include
|
||||
if (configMap.containsKey('_include')) {
|
||||
|
|
|
@ -33,6 +33,7 @@ Future<void> main() async {
|
|||
'angel': {'framework': 'cool'},
|
||||
'must_be_null': null,
|
||||
'artist': 'Timberlake',
|
||||
'included': true,
|
||||
'merge': {'map': true, 'hello': 'world'},
|
||||
'set_via': 'default',
|
||||
'hello': 'world',
|
||||
|
@ -40,6 +41,10 @@ Future<void> main() async {
|
|||
});
|
||||
});
|
||||
|
||||
test('obeys included paths', () async {
|
||||
expect(app.configuration['included'], true);
|
||||
});
|
||||
|
||||
test('can load based on ANGEL_ENV', () async {
|
||||
expect(app.configuration['hello'], equals('world'));
|
||||
expect(app.configuration['foo']['version'], equals('bar'));
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
_include:
|
||||
- "./include.yaml"
|
||||
hello: world
|
||||
foo:
|
||||
version: bar
|
||||
version: bar
|
||||
|
|
Loading…
Reference in a new issue