Allow for patching siteconfig settings in set-siteconfig.
Review Request #14213 — Created Oct. 28, 2024 and submitted
set-siteconfig
has historically been useful only for basic setting
management. It wasn't possible to set multiple settings, add new
settings, delete settings (restoring to defaults), or manipulating
lists. This made it very difficult to perform some kinds of settings
management without diving into Python code or modifying the database
more directly.Now,
set-siteconfig
can take either a JSON Patch or a JSON Merge
Patch, either as a string or read from STDIN. It'll apply to the
database, show a diff of the resulting settings, and prompt the user for
confirmation before applying the changes. This prompt is a safeguard in
case a patch does something unexpected, and can be disabled by passing
--confirm
(which is useful for automation).
--dry-run
can also be used to simulate making a change without
actually saving the new settings, helping people to test their patches.As a safeguard, patches that completely wipe settings can't be applied.
It's worth pointing out, though, that there are no safeguards against
applying invalid settings, a siteconfig settings do not currently offer
validation. That leaves this as an advanced feature that must be used
carefully.Setting individual keys using
--key
/--value
is still supported and
works as before. These do not provide validation, but they will show the
differences between settings. They do now respect the new--dry-run
setting.
Tested both patching options and the
--key
/--value
options. In each
case, I tested:
- Setting the existing values (no changes to save)
- With
--dry-run
- With
--confirm
- With manual prompting (and all Yes/No options), for patching.
Verified that diffing always looked correct and that settings applied
when confirmed.
Summary | ID |
---|---|
46ccbc42a4f36d63c71f232f0f3e2a7a9158b7a8 |
Description | From | Last Updated |
---|---|---|
Missing a "Raises" section in the docs. |
maubin |