Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

packagesets: add basic imagetype yaml to merge pkgSets #1298

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Mar 7, 2025

[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
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 force-pushed the yamlloader-merge-5 branch from cfacd62 to 3bfac4c Compare March 10, 2025 16:14
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