openQA Tests - coordination #15132: [saga][epic] Better structure of test plans in main.pm
Support !inherit tag in YAML job templates
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.
- AC1: A "deep merge" of multi-level YAML sections are possible within one YAML document with a special tag
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
The idea was to introduce a custom tag which will perform a deepmerge, so it could for example look like this:
def: - &default-template settings: a: A b: B desc: lala # ... - crypt: !inherit *default-template : settings: a: NEW A d: D
- crypt: desc: lala settings: a: NEW A b: B d: D
I implemented a proof of concept here: https://gist.github.com/perlpunk/f90f9a4f2ab36565c2f7da19d5bced7d
Such custom tags are used in Ansible and AWS Cloudformation, for example.