Provide way to re-export config and/or update hashes

Created on 29 June 2021, about 3 years ago
Updated 28 February 2024, 4 months ago

Problem/Motivation

As a developer using config_enforce with enforcement_level: 10 or lower, sometimes I know that config has changed (e.g.: via a distribution's update or post_update hooks), but I don't have a way to be confident that all of those config changes have been written to the config_enforce target module.

As a developer using config_enforce with others on a project, I sometimes run into a case where config_enforce hashes were accidentally not updated by another developer, meaning they show up as extraneous changes on my branch when config_enforce_devel decides to update them (not sure exactly when/how config_enforce_devel decides to do this). Similar to how composer update --lock updates the content-hash in composer.lock, it would be great to have a mechanism I could run before committing / pushing / merging to ensure that the config hashes in the config_enforce registry are up-to-date.

Note that when I say "re-export" here, I mean "copy active config to config_enforce target module".

Proposed resolution

I think at minimum, a "bulk operation" on the list of enforced configs at /admin/config/development/config_enforce/enforced_configs to re-export config and update hashes would be good. Or, ensure the that existing Update enforced config settings "bulk operation" will re-export API changes to the config AND update the config hashes.

Ideally, a drush command to re-export the config and update hashes would be even better.

Remaining tasks

  1. Write patch to update config_enforce_devel's UI
  2. Update patch with a Drush <=9 command
  3. Update patch with a Drush >=8 command
  4. Review and feedback
  5. RTBC and feedback
  6. Commit, release

User interface changes

Proposes adding a way to re-export the config and update hashes.

API changes

To be determined.

Data model changes

To be determined; likely none.

✨ Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

🇨🇦Canada mparker17 UTC-4

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada ergonlogic Montréal, Québec 🇨🇦

    Here's a patch that introduces a drush config-enforce:update command. It updates the hashes in all registries.

    Note that CED calculates hashes based on the already exported config files, rather than what's in active storage. Maybe we need to force config_devel to sync from active storage to disk first?

  • 🇨🇦Canada ergonlogic Montréal, Québec 🇨🇦

    Maybe we need to force config_devel to sync from active storage to disk first?

    Here's an updated patch that does essentially that. That is, it writes enforced configs to disk based on active storage, then updates all the registry hashes.

    One possible issue here is that enforced configs that are in config/optional may not have been imported yet. For example, if the site was just installed. So updating them may result in unwanted changes. This can be worked around, at the moment, by `git reset`ting files in config/optional.

    It'd probably be better to provide some CLI options to better control this.

  • 🇨🇦Canada ergonlogic Montréal, Québec 🇨🇦

    ✨ Provide mechanism to update stale registry settings Active is related, but covers edge-cases (such as a manually deleted config file). We should either consider those use-cases here, or follow-up from this ticket in the other one.

Production build 0.69.0 2024