Skip to content

distro/defs: drop the ImageTypeYAML property from defs.imageType - #2685

Merged
supakeen merged 13 commits into
osbuild:mainfrom
achilleas-k:plug-the-yaml-leaks
Sep 15, 2026
Merged

supakeen merged 13 commits into
osbuild:mainfrom
achilleas-k:plug-the-yaml-leaks

Conversation

@achilleas-k

@achilleas-k achilleas-k commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

The newImageTypeFrom() function now initialises the imageType with fully static properties and doesn't rely on the YAML backend.

Currently, this means that more work is done up front that may not be necessary. Image types are initialised and dynamic properties are resolved on startup rather than on-demand. However, future plans are for image types to be initialised dynamically in their entirety. This change makes the creation and usage of the defs.imageType type simpler.

The ImageTypeYAML is now not visible outside of the defs package where it serves the loader.

The bootcImageType still relies on embedding ImageTypeYAML for some methods. I'm planning on doing the same to the bootcImageType in a follow-up.

The first commit was originally #2675.

This commit moves everything from pkg/distro/generic/ into
pkg/distro/defs/.  Import paths have been adjusted throughout the
project.

The genManifest() function in bootc_test.go was rewritten to not depend
on manifestgen since that creates an import cycle.

The purpose of this change is to isolate any handling of image
definition loading and mentions of YAML to one package,
pkg/distro/defs/.  In the end, loading functionality and all types
initialised from the distro definitions will be defined in
pkg/distro/defs/.  YAML-specific types will be private and convert to
internal types for handling.  As much as possible, the properties of
these types will be immutable.

The GitLab CI config has been updated to test the new paths when
explicitly tested.
The error was being silently ignored while returning an empty imageType.
Add properties to the imageType struct to hold all required information
about the image type.  These are not used right now, but will be set
during initialisation instead of holding the ImageTypeYAML and using
that indirectly.
Instead of embedding ImageTypeYAML in imageType, add it as a regular
property.  This makes it clear and explicit what gets accessed from the
YAML backend and what's a property or method of the imageType itself.

The goal is to remove all YAML-backed data and types from the imageType
and resolve everything as soon as it's loaded, making the imageType as
static as possible.
Set and get some of the simple string properties of the imageType
directly from the imageType instead of the nested ImageTypeYAML.

One of the goals of this refactoring is to minimise the amount of
processing in the accessor methods.  Anything that can be set statically
during initialisation should be.  The supported blueprint options are
the first example of this.  The appending of the three common/default
metadata properties is added during initialisation instead of being part
of the SupportedBlueprintOptions() method.

One small change in behaviour: The Exports() method no longer returns
["assembler"] when the field is not set.  That fallback mechanism was
added to support image types configured to generate v1 manifests for
osbuild, which haven't been relevant for a few years now.
The ErrNoPartitionTableForImgType requires the image type name as
argument but we were setting the distro ID instead.
Resolve the partition table for the given distro, architecture, and
image type combination during image type initialisation and set it
statically as a property on the imageType.
In the ostree URL accessor, there's no need to check if the image type
is ostree-based.  A non-ostree-based image will have an empty URL.
Render the ISO label and set it on the imageType during initialisation.
The isoLabel on the image type is now a string instead of a function.
The getISOLabelFunc() has been renamed to resolveISOLabel() and now
takes a template and architecture name and renders the ISO label string.
Resolve the imageConfig, installerConfig, isoConfig, and diskConfig and
set them on the imageType during initialisation.
Resolve the package sets and set them on the imageType during
initialisaion.
Move the internal method up onto the imageType instead of relying on the
ImageTypeYAML backend.
The newImageTypeFrom() function now initialises the imageType with fully
static properties and doesn't rely on the YAML backend.

Currently, this means that more work is done up front that may not be
necessary.  Image types are initialised and dynamic properties are
resolved on startup rather than on-demand.  However, future plans are
for image types to be initialised dynamically in their entirety.  This
change makes the creation and usage of the defs.imageType type simpler.

The ImageTypeYAML is now not visible outside of the defs package where
it serves the loader.

The bootcImageType still relies on embedding ImageTypeYAML for some
methods.
@supakeen

Copy link
Copy Markdown
Member

I think this will (hopefully) fit nicely with making it a bit more standardized when templates are resolved in the future. I'll take a look soon.

@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.

This ... is extremely clean for so many changes even if mostly mechanical.

@supakeen
supakeen added this pull request to the merge queue Sep 15, 2026
Merged via the queue into osbuild:main with commit 05a4444 Sep 15, 2026
54 checks passed
@achilleas-k
achilleas-k deleted the plug-the-yaml-leaks branch September 15, 2026 09:43
achilleas-k added a commit to achilleas-k/osbuild-composer that referenced this pull request Sep 17, 2026
Update the image-builder dependency.
Some import paths needed adjustment due to
osbuild/image-builder#2685.
achilleas-k added a commit to achilleas-k/osbuild-composer that referenced this pull request Sep 18, 2026
Update the image-builder dependency.
Some import paths needed adjustment due to
osbuild/image-builder#2685.
avitova pushed a commit to osbuild/osbuild-composer that referenced this pull request Sep 21, 2026
Update the image-builder dependency.
Some import paths needed adjustment due to
osbuild/image-builder#2685.
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.

2 participants