You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,11 @@ All notable changes to this project will be documented in this file.
7
7
### Added
8
8
9
9
- Allow to pass a `ignore_missing_paths` parameter to each config method
10
+
- Support for Hashicorp Vault credentials (in `config.contrib`)
11
+
12
+
### Changed
13
+
14
+
- Added a `validate` method to validate `Configuration` instances against a [json schema](https://json-schema.org/understanding-json-schema/basics.html#basics).
Copy file name to clipboardExpand all lines: README.md
+58-1Lines changed: 58 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -276,13 +276,62 @@ When setting the `interpolate` parameter in any `Configuration` instance, the li
276
276
cfg = config_from_dict({
277
277
"percentage": "{val:.3%}",
278
278
"with_sign": "{val:+f}",
279
-
"val": 1.23456}, interpolate=True)
279
+
"val": 1.23456,
280
+
}, interpolate=True)
280
281
281
282
assert cfg.val ==1.23456
282
283
assert cfg.with_sign =="+1.234560"
283
284
assert cfg.percentage =="123.456%"
284
285
```
285
286
287
+
###### Validation
288
+
289
+
Validation relies on the [jsonchema](https://github.com/python-jsonschema/jsonschema) library, which is automatically installed using the extra `validation`. To use it, call the `validate` method on any `Configuration` instance in a manner similar to what is described on the `jsonschema` library:
# pass the `raise_on_error` parameter to get the traceback of validation failures
307
+
cfg.validate(schema, raise_on_error=True)
308
+
# ValidationError: 'Invalid' is not of type 'number'
309
+
```
310
+
311
+
To use the [format](https://python-jsonschema.readthedocs.io/en/latest/validate/#validating-formats) feature of the `jsonschema` library, the extra dependencies must be installed separately as explained in the documentation of `jsonschema`.
The `config.contrib` package contains extra implementations of the `Configuration` class used for special cases. Currently the following are implemented:
@@ -311,6 +360,14 @@ The `config.contrib` package contains extra implementations of the `Configuratio
311
360
pip install python-configuration[gcp]
312
361
```
313
362
363
+
*`HashicorpVaultConfiguration` in `config.contrib.vault`, which takes Hashicorp Vault
364
+
credentials into a `Configuration`-compatible instance. To install the needed dependencies
0 commit comments