Skip to content

Commit e0f429b

Browse files
committed
Add "Overriding defaults from one file to the next" from #87
1 parent a176183 commit e0f429b

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

docs/usage/loading.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,24 @@ connection = connect(**config.service)
6969
# and some extra things that configure the place to backup to
7070
connection.backup_to(config.paths.backup)
7171
```
72+
73+
## Overriding defaults from one file to the next
74+
75+
If values from multiple files overlap (like if `/etc/paths.yaml` would contain `service.port: 80`), things become slightly more complicated.
76+
Confidence uses a predictable precedence of content here: the value that gets loaded last has the highest precedence (or 'wins').
77+
`loadf` will load content in the order of the arguments that get passed, so `service.port` would be 443, as defined in `path/to/service.yaml`.
78+
You can use this behaviour to define defaults somewhere, that get overridden later:
79+
80+
```yaml
81+
# some system-wide configuration in /etc/paths.yaml
82+
service.port: 80
83+
paths:
84+
data: /storage/data
85+
backup: /mnt/backup/data
86+
```
87+
88+
```yaml
89+
service:
90+
host: example.com
91+
port: 443
92+
```

0 commit comments

Comments
 (0)