Problem/Motivation
Alongside the existing wildcard support in recipes for extension config installation, it would be valuable to provide an option through which recipe authors could have config from config/optional install conditionally.
Per the recipe authors guide, a recipe author at present:
can use a
*wildcard to install all configuration the module provides. This will install all configuration in the module'sconfig/installandconfig/optionaldirectories. It does not filter out optional configuration that is missing dependencies. It is up to the recipe author to ensure that all the optional configuration dependencies are installed.
This approach is consistent with what's been termed the deterministic intent of recipes: that the recipe author should have full control of the applied state of a recipe.
However, in practice, supporting only the deterministic model in which a wildcard requires installation of all optional configuration has raised significant challenges for recipe authors, as evident in various posts within and outside the issue queue, including:
- #3393086: Optional configuration is imported even when module dependencies aren't there.
- #3560174: Filter out optional config with missing dependencies
- #3560179: Support installing all module configuration entities via recipes
- #3478921: A recipe should install new modules in the same way/result as modules installed via the UI or CLI.
- This discussion in #recipes in Slack: "Can we revive the discussion in https://www.drupal.org/project/distributions_recipes/issues/3393086 based on the fact that we are using
'*'as a workaround for some other.... undesirable behaviours?"
Within recipe development, there is already a significant record of providing more flexible approaches alongside the more verbose and deterministic ones. A key example is #3552023: Recipes should support skipping config actions on entities that don't exist. From that issue's summary:
There are cases where a recipe needs to do config actions on an entity...if, and only if, it exists. If the entity doesn't exist, the config actions should obviously be bypassed.
Recipes should have an explicit syntax for this, enabling smooth and optional integrations.
Steps to reproduce
Proposed resolution
Alongside the '*' wildcard for an extension's config, support a new selector (similar to that introduced for optional config actions) that would install config in config/required and the subset of config in config/optional for which the conditions for installation are met.
By adding a new selector, we ensure that the current wildcard functionality remains unchanged. All existing recipes are unaffected and continue to behave just like they do at present. Just as was done in the case of optional (or, perhaps better put, conditional) config actions, we are providing additional flexibility for recipe authors without undermining the core assumptions or functionality of recipe design.
Proposed syntax:
config:
import:
# Import all module1 config from config/install and config/optional.
module1: '*'
# Import all module2 config from config/install and any config from config/optional
# for which the conditions for installation are met.
module2: '?*'
Comments