From 4085cd135979bba14941a8f9c39d8bcb0eaaff27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Budai?= Date: Thu, 12 Dec 2024 09:55:39 +0100 Subject: [PATCH] rhel: allow overrdiding the spec directory People don't like the packages that we picked for individual types? They can now create their own spec directories, and pass them via OSBUILD_IMAGES_IMAGE_SPECS_DIR. This obviously should not be an environment variable, but this is the easiest first step that we can make. --- pkg/distro/rhel/imagetype.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/distro/rhel/imagetype.go b/pkg/distro/rhel/imagetype.go index d61ab312b..e31eaf16d 100644 --- a/pkg/distro/rhel/imagetype.go +++ b/pkg/distro/rhel/imagetype.go @@ -3,7 +3,9 @@ package rhel import ( "bytes" "fmt" + "io/fs" "math/rand" + "os" "slices" @@ -295,12 +297,22 @@ func (t *ImageType) Manifest(bp *blueprint.Blueprint, } `yaml:"spec"` } - configFile, err := spec.FindBestConfig(specs.Data, t.arch.Distro().Name(), t.Arch().Name(), t.Name()) + // Allow overriding the embedded image type specs with an external directory + // This is of course absolutely misplaces, and should not be passed in as an + // environment variable, but it's good enough for a showcase. + // TODO: Make this more sane + var configDir fs.ReadDirFS + configDir = specs.Data + if overrideConfigDir, found := os.LookupEnv("OSBUILD_IMAGES_IMAGE_SPECS_DIR"); found { + configDir = os.DirFS(overrideConfigDir).(fs.ReadDirFS) + } + + configFile, err := spec.FindBestConfig(configDir, t.arch.Distro().Name(), t.Arch().Name(), t.Name()) if err != nil { return nil, nil, fmt.Errorf("failed to find image type spec: %w", err) } - rawSpec, err := spec.MergeConfig(specs.Data, configFile) + rawSpec, err := spec.MergeConfig(configDir, configFile) if err != nil { return nil, nil, fmt.Errorf("failed to merge image type spec: %w", err) }