• 
      

    Allow for patching siteconfig settings in set-siteconfig.

    Review Request #14213 — Created Oct. 29, 2024 and submitted — Latest diff uploaded

    Information

    Djblets
    release-5.x

    Reviewers

    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:

    1. Setting the existing values (no changes to save)
    2. With --dry-run
    3. With --confirm
    4. With manual prompting (and all Yes/No options), for patching.

    Verified that diffing always looked correct and that settings applied
    when confirmed.

    Commits

    Files