Skip to content

packagesets: add basic imagetype yaml to merge pkgSets - #1298

Merged
ondrejbudai merged 1 commit into
osbuild:mainfrom
mvo5:yamlloader-merge-5
Mar 13, 2025
Merged

ondrejbudai merged 1 commit into
osbuild:mainfrom
mvo5:yamlloader-merge-5

Conversation

@mvo5

@mvo5 mvo5 commented Mar 7, 2025 •

Copy link
Copy Markdown
Contributor

[this is my personal winner in the race for best-yaml-for-shareing-pkgsets, based on a new idea of @ondrejbudai (thanks!), see also https://github.com//pull/1294 and https://github.com//pull/1296 and https://github.com//pull/1295]

This commit adds a basic imagetype yaml to support merging of package sets This is a useful feature so that we can e.g. avoid duplicating the cloud_base or anaconda package sets.

It works by adding new toplevels "image_types" in the package_sets.yaml and then using anchors/refs to refer to them in the image_type yaml. To allow sharing yaml that is not part of an image_type it also introduces a top-level .common that can have any yaml in it.

It allows us to write:

.common:
  base: &base_pkgset
    include: [from-base-inc]
    exclude: [from-base-exc]
    condition:
      distro_name:
        test-distro:
          include: [from-base-condition-inc]
          exclude: [from-base-condition-exc]

image_types:
  other_type:
    package_sets:
      - &other_type_pkgset
        include: [from-other-type-inc]
        exclude: [from-other-type-exc]
  test_type:
    package_sets:
      - *base_pkgset
      - *other_type_pkgset
      - include: [from-type-inc]
        exclude: [from-type-exc]
        condition:
          distro_name:
            test-distro:
              include: [from-condition-inc]
              exclude: [from-condition-exc]

The downside of this approach is that:

  1. it requires the anchor to be there before the ref, which can be confusing (we could solve this later via includes)
  2. if the anchor is forgotten the error becomes very obscure
  3. its a bit "hardcore" yaml

The upside is that it is very symetrical and actually feels quite nice.

@mvo5 mvo5 changed the title [RFC] packagesets: add basic imagetype yaml to merge pkgSets [RFC] packagesets: add basic imagetype yaml to merge pkgSets (winner) Mar 7, 2025
@mvo5 mvo5 changed the title [RFC] packagesets: add basic imagetype yaml to merge pkgSets (winner) [RFC] packagesets: add basic imagetype yaml to merge pkgSets (winner?) Mar 7, 2025
@mvo5 mvo5 changed the title [RFC] packagesets: add basic imagetype yaml to merge pkgSets (winner?) [RFC] packagesets: add basic imagetype yaml to merge pkgSets (winner? symetric++) Mar 7, 2025
@mvo5
mvo5 marked this pull request as ready for review March 7, 2025 15:08
@mvo5
mvo5 requested a review from a team as a code owner March 7, 2025 15:08
@mvo5
mvo5 requested a review from thozza March 7, 2025 15:08
@mvo5 mvo5 changed the title [RFC] packagesets: add basic imagetype yaml to merge pkgSets (winner? symetric++) packagesets: add basic imagetype yaml to merge pkgSets (winner? symetric++) Mar 7, 2025
@mvo5 mvo5 changed the title packagesets: add basic imagetype yaml to merge pkgSets (winner? symetric++) packagesets: add basic imagetype yaml to merge pkgSets Mar 10, 2025
@mvo5
mvo5 force-pushed the yamlloader-merge-5 branch from cfacd62 to 3bfac4c Compare March 10, 2025 16:14
achilleas-k
achilleas-k previously approved these changes Mar 12, 2025

@achilleas-k achilleas-k left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this a bit offline but I'd like to repeat my thoughts here for posterity.

I like this! At first I was a bit hesitant about using too many yaml features, but I think it makes sense. It means we don't have to have obscure code constructs and internal rules for merging sets and if people want to define their sets without using all the references and fancy merging they can just write straight-up plain yaml without any of this and without needing to think about how it might interact with our internals.

supakeen
supakeen previously approved these changes Mar 12, 2025

@supakeen supakeen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this is definitely the winner in my book. As close to "standards" as one can get with YAML I guess? :)

@mvo5
mvo5 dismissed stale reviews from supakeen and achilleas-k via a1ef5b7 March 13, 2025 08:12
@mvo5
mvo5 force-pushed the yamlloader-merge-5 branch from 3bfac4c to a1ef5b7 Compare March 13, 2025 08:12
@mvo5

mvo5 commented Mar 13, 2025 •

Copy link
Copy Markdown
Contributor Author

Thanks! I had to rebase because of conflicts but this should be good (again) now.

@mvo5
mvo5 requested review from achilleas-k and supakeen March 13, 2025 08:13
supakeen
supakeen previously approved these changes Mar 13, 2025
ondrejbudai
ondrejbudai previously approved these changes Mar 13, 2025

@ondrejbudai ondrejbudai left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it! Feels very straightforward. :)

This commit adds a basic imagetype yaml to support merging
of package sets  This is a useful feature so that we can e.g.
avoid duplicating the `cloud_base` or `anaconda` package sets.

It works by adding new toplevels "image_types" in the
package_sets.yaml and then using anchors/refs to refer to
them in the image_type yaml. To allow sharing yaml that is
not part of an image_type it also introduces a top-level
`.common` that can have `any` yaml in it.

It allows us to write:
```yaml
.common:
  base: &base_pkgset
    include: [from-base-inc]
    exclude: [from-base-exc]
    condition:
      distro_name:
        test-distro:
          include: [from-base-condition-inc]
          exclude: [from-base-condition-exc]

image_types:
  other_type:
    package_sets:
      - &other_type_pkgset
        include: [from-other-type-inc]
        exclude: [from-other-type-exc]
  test_type:
    package_sets:
      - *base_pkgset
      - *other_type_pkgset
      - include: [from-type-inc]
        exclude: [from-type-exc]
        condition:
          distro_name:
            test-distro:
              include: [from-condition-inc]
              exclude: [from-condition-exc]
```
The downside of this approach is that:
1. it requires the anchor to be there before the ref, which can
   be confusing (we could solve this later via includes)
2. if the anchor is forgotten the error becomes very obscure
3. its a bit "hardcore" yaml

The upside is that it is very symetrical and actually feels quite
nice.
@mvo5
mvo5 dismissed stale reviews from ondrejbudai and supakeen via 64e27d4 March 13, 2025 11:27
@mvo5
mvo5 force-pushed the yamlloader-merge-5 branch from a1ef5b7 to 64e27d4 Compare March 13, 2025 11:27
@mvo5

mvo5 commented Mar 13, 2025

Copy link
Copy Markdown
Contributor Author

Thanks! I had to rebase again because of conflicts - sorry for that (there was a bit of a backlog in this area but this should be the last rebase)

@thozza thozza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, I love it 🚀

@ondrejbudai
ondrejbudai enabled auto-merge March 13, 2025 12:32

@ondrejbudai ondrejbudai left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go!

@ondrejbudai
ondrejbudai added this pull request to the merge queue Mar 13, 2025
Merged via the queue into osbuild:main with commit d91c5c7 Mar 13, 2025
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.

5 participants