Make config set create a list for an index under a missing key (closes #308)
check / check (push) Waiting to run
check / check (push) Waiting to run
`config set age_recipients.0 age1...` on a file without `age_recipients`
created a map keyed `0` and wrote it, after which every command failed
to parse the config. A missing key is now created as a list when the
next path element is a number, and an index that list cannot take is an
error.
`config set` now decodes its result into the config type before
writing, and on failure refuses and leaves the file unchanged. It does
not validate: settings are set one at a time, and validation would
refuse a config still being filled in.
Judgement call: a `${...}` reference set on a setting that is not text
is now refused, since it decodes as text; `config edit` can still write
one.
Rule suppressed: gosec G304 where the new test reads back its own temp
file, as the other config tests do.
Model: opus-5-5
This commit is contained in:
@@ -271,8 +271,14 @@ existing file. Created with mode `0600` since it will contain credentials.
|
||||
**`config set`**: Set a scalar config value by dotted YAML path
|
||||
(e.g. `vaultik config set compression_level 9`,
|
||||
`vaultik config set storage_url "file:///mnt/backups"`). Comments and
|
||||
formatting in the file are preserved; intermediate maps are created as
|
||||
needed.
|
||||
formatting in the file are preserved. Missing keys along the path are
|
||||
created: as a list when the next path element is a number (so
|
||||
`vaultik config set age_recipients.0 age1...` works on a file without
|
||||
`age_recipients`), otherwise as a map. A change that gives a setting the
|
||||
wrong type, such as a single value where a list belongs or a word where
|
||||
a number belongs, is refused and the file is left unchanged. Whether the
|
||||
config is complete and its values are in range is checked when a command
|
||||
loads it, not by `config set`, so settings can be set one at a time.
|
||||
|
||||
**`snapshot create`**: Perform incremental backup of configured snapshots.
|
||||
* Optional snapshot names argument to create specific snapshots (default: all)
|
||||
|
||||
Reference in New Issue
Block a user