Skip to content

Commit

Permalink
rhel: allow overrdiding the spec directory
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ondrejbudai committed Dec 12, 2024
1 parent d6a41a1 commit 4085cd1
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pkg/distro/rhel/imagetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package rhel
import (
"bytes"
"fmt"
"io/fs"
"math/rand"
"os"

"slices"

Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 4085cd1

Please sign in to comment.