Improve the error message when a configuration override contains an invalid value (#528).
This commit is contained in:
parent
1921f55a9d
commit
51fc37d57a
3 changed files with 23 additions and 11 deletions
1
NEWS
1
NEWS
|
@ -1,4 +1,5 @@
|
|||
1.6.1.dev0
|
||||
* #528: Improve the error message when a configuration override contains an invalid value.
|
||||
* #532: When a configuration include is a relative path, load it from either the current working
|
||||
directory or from the directory containing the file doing the including. (Previously, only the
|
||||
working directory was used.)
|
||||
|
|
|
@ -52,16 +52,20 @@ def parse_overrides(raw_overrides):
|
|||
if not raw_overrides:
|
||||
return ()
|
||||
|
||||
try:
|
||||
return tuple(
|
||||
(tuple(raw_keys.split('.')), convert_value_type(value))
|
||||
for raw_override in raw_overrides
|
||||
for raw_keys, value in (raw_override.split('=', 1),)
|
||||
)
|
||||
except ValueError:
|
||||
raise ValueError('Invalid override. Make sure you use the form: SECTION.OPTION=VALUE')
|
||||
except ruamel.yaml.error.YAMLError as error:
|
||||
raise ValueError(f'Invalid override value: {error}')
|
||||
parsed_overrides = []
|
||||
|
||||
for raw_override in raw_overrides:
|
||||
try:
|
||||
raw_keys, value = raw_override.split('=', 1)
|
||||
parsed_overrides.append((tuple(raw_keys.split('.')), convert_value_type(value),))
|
||||
except ValueError:
|
||||
raise ValueError(
|
||||
f"Invalid override '{raw_override}'. Make sure you use the form: SECTION.OPTION=VALUE"
|
||||
)
|
||||
except ruamel.yaml.error.YAMLError as error:
|
||||
raise ValueError(f"Invalid override '{raw_override}': {error.problem}")
|
||||
|
||||
return tuple(parsed_overrides)
|
||||
|
||||
|
||||
def apply_overrides(config, raw_overrides):
|
||||
|
|
|
@ -176,7 +176,14 @@ borgmatic create --override location.repositories=[test1.borg,test2.borg]
|
|||
Or even a single list element:
|
||||
|
||||
```bash
|
||||
borgmatic create --override location.repositories=[/root/test1.borg]
|
||||
borgmatic create --override location.repositories=[/root/test.borg]
|
||||
```
|
||||
|
||||
If your override value contains special YAML characters like colons, then
|
||||
you'll need quotes for it to parse correctly:
|
||||
|
||||
```bash
|
||||
borgmatic create --override location.repositories="['user@server:test.borg']"
|
||||
```
|
||||
|
||||
There is not currently a way to override a single element of a list without
|
||||
|
|
Loading…
Reference in a new issue