Project

General

Profile

action #66865

Updated by okurz 6 months ago

## Motivation

Our extensive use of YAML merge keys `<<` is hitting limits. Only the top level is merged. In the context of scenarios it can be more desirable to include settings, which are at the second level.

## Acceptance criteria
* **AC1:** A "deep merge" of multi-level YAML sections are possible within one YAML document with a special tag

## Suggestions

tinita wrote:
> Just a note: YAML Merge Keys `<<` are not performing a "deep merge". It only merges at the top level.
> So in the following example the settings would only contain the `ANOTHER_SETTING`.
>
> ```
> - .testsuite: &crypt_no_lvm
> description: |
> bla bla bla
> settings:
> YAML_SCHEDULE: schedule/yast/encryption/crypt_no_lvm.yaml
> YAML_TEST_DATA: test_data/yast/encryption/encrypt_no_lvm.yaml
> - crypt_no_lvm:
> settings:
> ANOTHER_SETTING: foo
> <<: *crypt_no_lvm
> ```
> Resulting data with resolved merge keys:
> ```
> - .testsuite:
> description: |
> bla bla bla
> settings:
> YAML_SCHEDULE: schedule/yast/encryption/crypt_no_lvm.yaml
> YAML_TEST_DATA: test_data/yast/encryption/encrypt_no_lvm.yaml
> - crypt_no_lvm:
> description: |
> bla bla bla
> settings:
> ANOTHER_SETTING: foo
> ```

A custom tag which I will call `!inherit` could fix that. And although I'm hesistant to diverge from standard YAML, I think we could try and keep it generic and straightforward to implement in e.g. YAML schedules or Python code.

Proposal in #66865#note-1 **(Proposal to follow)**

Back