Skip to content

Improvements to the config parser#43

Open
hnez wants to merge 7 commits intoforrest-runner:mainfrom
hnez:recursive-merges
Open

Improvements to the config parser#43
hnez wants to merge 7 commits intoforrest-runner:mainfrom
hnez:recursive-merges

Conversation

@hnez
Copy link
Copy Markdown
Member

@hnez hnez commented Mar 2, 2026

We had to work around missing support for recursive YAML merges in our serde_yaml* / yaml_serde crates for some time now, by writing the configs in a special way.

Work around that once and for all by just applying merges in a loop until they are all resolved.

Also change some other bits and bobs around the config parsing, while at it.

This PR is based on #42 because that switched from sede_yaml_ng to yaml_serde.

@hnez hnez requested a review from jluebbe March 2, 2026 12:21
@hnez hnez force-pushed the recursive-merges branch from bf9bdf6 to 9ccee41 Compare March 2, 2026 12:24
hnez added 7 commits March 3, 2026 07:04
This is similar to how GitLab CI handles reusable YAML snippets and is
(in my opinion) prettier and more flexible than the previous top level
`*_snippet`s (which stay usable for backward compatibility reasons).

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
This allows using snippets like these, which already include `<<` merges:

    machine-small: &machine-small
      setup_template:
        path: /etc/forrest/templates/generic
        parameters:
          RUNNER_VERSION: "2.318.0"
          RUNNER_HASH: "28ed88e4cedf0fc93201a901e392a70463dbd0213f2ce9d57a4ab495027f3e2f"
      base_image: /srv/forrest/images/debian-12-generic-amd64.raw
      cpus: 4
      disk: 16G
      ram: 4G
    machine-medium: &machine-medium
      << : *machine-small
      cpus: 8
      disk: 32G
      ram: 8G

And then using them in e.g. machine definitions, just like one would
expect:

    forrest-test:
      machines:
        test-debian:
          << : *machine-medium
          base_machine: hnez/forrest-images/debian-base

This does not work by default in yaml_serde (0.10) because merges in
mappings are not applied recursively.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
This makes it easier to write tests in the future.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
Right now there is only one, but everyone has to start small.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
@hnez hnez force-pushed the recursive-merges branch from 9ccee41 to a7f8402 Compare March 3, 2026 06:04
@hnez
Copy link
Copy Markdown
Member Author

hnez commented Mar 24, 2026

Maybe use serde-saphyr instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant