RHEL-84: extend imageTypeS2 to contain pipelines generator function

Extend RHEL-84 `imageTypeS2` structure to contain pipelines generator
function. Previously, the `imageTypeS2` implementation defaulted to only
a single pipelines generator method for EDGE image types. The ability to
pass a different generator function implementation is important to
enable addition of new image types relying on osbuild Manifest v2.

Rename the original pipeline generator method to `edgePipelines`.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
Tomas Hozza 2022-02-15 15:01:19 +01:00 committed by Tom Gundersen
parent 77b5ef459d
commit 2a8e6123aa
2 changed files with 9 additions and 2 deletions

View file

@ -179,6 +179,7 @@ func (a *architecture) addS2ImageTypes(imageTypes ...imageTypeS2) {
buildPipelines: it.buildPipelines,
payloadPipelines: it.payloadPipelines,
exports: it.exports,
pipelines: it.pipelines,
}
}
}
@ -1300,6 +1301,7 @@ func newDistro(name, modulePlatformID, ostreeRef string, isCentos bool) distro.D
enabledServices: edgeImgTypeX86_64.enabledServices,
rpmOstree: true,
bootISO: false,
pipelines: edgePipelines,
}
edgeBuildPkgs := []string{
@ -1524,6 +1526,7 @@ func newDistro(name, modulePlatformID, ostreeRef string, isCentos bool) distro.D
buildPipelines: []string{"build"},
payloadPipelines: []string{"anaconda-tree", "bootiso-tree", "assembler"},
exports: []string{"assembler"},
pipelines: edgePipelines,
}
edgeOCIImgTypeAarch64 := imageTypeS2{
@ -1543,6 +1546,7 @@ func newDistro(name, modulePlatformID, ostreeRef string, isCentos bool) distro.D
buildPipelines: []string{"build"},
payloadPipelines: []string{"ostree-tree", "ostree-commit", "container-tree", "assembler"},
exports: []string{"assembler"},
pipelines: edgePipelines,
}
x8664.addImageTypes(

View file

@ -18,6 +18,8 @@ const (
kspath = "/usr/share/anaconda/interactive-defaults.ks"
)
type pipelinesFunc func(t *imageTypeS2, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]osbuild.Pipeline, error)
type imageTypeS2 struct {
arch *architecture
name string
@ -35,6 +37,7 @@ type imageTypeS2 struct {
buildPipelines []string
payloadPipelines []string
exports []string
pipelines pipelinesFunc
}
func (t *imageTypeS2) Arch() distro.Arch {
@ -152,7 +155,7 @@ func (t *imageTypeS2) Manifest(c *blueprint.Customizations,
// math/rand is good enough in this case
/* #nosec G404 */
rng := rand.New(source)
pipelines, err := t.pipelines(c, options, repos, packageSpecSets, rng)
pipelines, err := t.pipelines(t, c, options, repos, packageSpecSets, rng)
if err != nil {
return distro.Manifest{}, err
}
@ -216,7 +219,7 @@ func (t *imageTypeS2) sources(packages []rpmmd.PackageSpec, ostreeCommits []ostr
return sources
}
func (t *imageTypeS2) pipelines(customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]osbuild.Pipeline, error) {
func edgePipelines(t *imageTypeS2, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]osbuild.Pipeline, error) {
if t.bootISO {
if options.OSTree.Parent == "" {