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's config/install and config/optional directories. 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:

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: '?*'

Remaining tasks

User interface changes

API changes

Data model changes

Comments

nedjo created an issue.