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

Add support for otk-defined distributions (COMPOSER-2299) #797

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/osbuild-playground/my-container.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func init() {
// Return nil when you are done, or an error if something
// went wrong. Your manifest will be streamed to osbuild
// for building.
func (img *MyContainer) InstantiateManifest(m *manifest.Manifest,
func (img *MyContainer) InstantiateManifest(m manifest.Manifest,
repos []rpmmd.RepoConfig,
runner runner.Runner,
rng *rand.Rand) (*artifact.Artifact, error) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/osbuild-playground/my-image.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func init() {
AddImageType(&MyImage{})
}

func (img *MyImage) InstantiateManifest(m *manifest.Manifest,
func (img *MyImage) InstantiateManifest(m manifest.Manifest,
repos []rpmmd.RepoConfig,
runner runner.Runner,
rng *rand.Rand) (*artifact.Artifact, error) {
Expand Down
4 changes: 2 additions & 2 deletions cmd/osbuild-playground/playground.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ func RunPlayground(img image.ImageKind, d distro.Distro, arch distro.Arch, repos
// Set cache size to 1 GiB
solver.SetMaxCacheSize(1 * common.GiB)

manifest := manifest.New()
manifest := manifest.New(manifest.DISTRO_FEDORA)

/* #nosec G404 */
rnd := rand.New(rand.NewSource(0))

// TODO: query distro for runner
artifact, err := img.InstantiateManifest(&manifest, repos[arch.Name()], &runner.Fedora{Version: 36}, rnd)
artifact, err := img.InstantiateManifest(manifest, repos[arch.Name()], &runner.Fedora{Version: 36}, rnd)
if err != nil {
panic("InstantiateManifest() failed: " + err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/distro/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ type ImageType interface {
// specified in the given blueprint; it also returns any warnings (e.g.
// deprecation notices) generated by the manifest.
// The packageSpecSets must be labelled in the same way as the originating PackageSets.
Manifest(bp *blueprint.Blueprint, options ImageOptions, repos []rpmmd.RepoConfig, seed int64) (*manifest.Manifest, []string, error)
Manifest(bp *blueprint.Blueprint, options ImageOptions, repos []rpmmd.RepoConfig, seed int64) (manifest.Manifest, []string, error)
}

// The ImageOptions specify options for a specific image build
Expand Down
9 changes: 4 additions & 5 deletions pkg/distro/fedora/imagetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (t *imageType) PartitionType() string {
func (t *imageType) Manifest(bp *blueprint.Blueprint,
options distro.ImageOptions,
repos []rpmmd.RepoConfig,
seed int64) (*manifest.Manifest, []string, error) {
seed int64) (manifest.Manifest, []string, error) {

warnings, err := t.checkOptions(bp, options)
if err != nil {
Expand Down Expand Up @@ -256,14 +256,13 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
if err != nil {
return nil, nil, err
}
mf := manifest.New()
mf.Distro = manifest.DISTRO_FEDORA
_, err = img.InstantiateManifest(&mf, repos, t.arch.distro.runner, rng)
mf := manifest.New(manifest.DISTRO_FEDORA)
_, err = img.InstantiateManifest(mf, repos, t.arch.distro.runner, rng)
if err != nil {
return nil, nil, err
}

return &mf, warnings, err
return mf, warnings, err
}

// checkOptions checks the validity and compatibility of options and customizations for the image type.
Expand Down
16 changes: 8 additions & 8 deletions pkg/distro/rhel/imagetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (t *ImageType) PartitionType() string {
func (t *ImageType) Manifest(bp *blueprint.Blueprint,
options distro.ImageOptions,
repos []rpmmd.RepoConfig,
seed int64) (*manifest.Manifest, []string, error) {
seed int64) (manifest.Manifest, []string, error) {

if t.Workload != nil {
// For now, if an image type defines its own workload, don't allow any
Expand Down Expand Up @@ -307,27 +307,27 @@ func (t *ImageType) Manifest(bp *blueprint.Blueprint,
if err != nil {
return nil, nil, err
}
mf := manifest.New()

var mf manifest.Manifest
switch t.Arch().Distro().Releasever() {
case "7":
mf.Distro = manifest.DISTRO_EL7
mf = manifest.New(manifest.DISTRO_EL7)
case "8":
mf.Distro = manifest.DISTRO_EL8
mf = manifest.New(manifest.DISTRO_EL8)
case "9":
mf.Distro = manifest.DISTRO_EL9
mf = manifest.New(manifest.DISTRO_EL9)
case "10":
mf.Distro = manifest.DISTRO_EL10
mf = manifest.New(manifest.DISTRO_EL10)
default:
return nil, nil, fmt.Errorf("unsupported distro release version: %s", t.Arch().Distro().Releasever())
}

_, err = img.InstantiateManifest(&mf, repos, t.arch.distro.runner, rng)
_, err = img.InstantiateManifest(mf, repos, t.arch.distro.runner, rng)
if err != nil {
return nil, nil, err
}

return &mf, warnings, err
return mf, warnings, err
}

// checkOptions checks the validity and compatibility of options and customizations for the image type.
Expand Down
4 changes: 2 additions & 2 deletions pkg/distro/test_distro/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (t *TestImageType) Exports() []string {
return distro.ExportsFallback()
}

func (t *TestImageType) Manifest(b *blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig, seed int64) (*manifest.Manifest, []string, error) {
func (t *TestImageType) Manifest(b *blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig, seed int64) (manifest.Manifest, []string, error) {
var bpPkgs []string
if b != nil {
mountpoints := b.Customizations.GetFilesystems()
Expand Down Expand Up @@ -297,7 +297,7 @@ func (t *TestImageType) Manifest(b *blueprint.Blueprint, options distro.ImageOpt
},
}

m := &manifest.Manifest{}
m := manifest.New(manifest.DISTRO_NULL)

manifest.NewContentTest(m, buildPkgsKey, buildPackages, nil, nil)
manifest.NewContentTest(m, osPkgsKey, osPackages, nil, ostreeSources)
Expand Down
2 changes: 2 additions & 0 deletions pkg/distrofactory/distrofactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/osbuild/images/pkg/distro/rhel/rhel8"
"github.com/osbuild/images/pkg/distro/rhel/rhel9"
"github.com/osbuild/images/pkg/distro/test_distro"
"github.com/osbuild/images/pkg/otkdistro"
)

// FactoryFunc is a function that returns a distro.Distro for a given distro
Expand Down Expand Up @@ -114,6 +115,7 @@ func NewDefault() *Factory {
rhel8.DistroFactory,
rhel9.DistroFactory,
rhel10.DistroFactory,
otkdistro.DistroFactory,
)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/image/anaconda_container_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func NewAnacondaContainerInstaller(container container.SourceSpec, ref string) *
}
}

func (img *AnacondaContainerInstaller) InstantiateManifest(m *manifest.Manifest,
func (img *AnacondaContainerInstaller) InstantiateManifest(m manifest.Manifest,
repos []rpmmd.RepoConfig,
runner runner.Runner,
rng *rand.Rand) (*artifact.Artifact, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/anaconda_live_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewAnacondaLiveInstaller() *AnacondaLiveInstaller {
}
}

func (img *AnacondaLiveInstaller) InstantiateManifest(m *manifest.Manifest,
func (img *AnacondaLiveInstaller) InstantiateManifest(m manifest.Manifest,
repos []rpmmd.RepoConfig,
runner runner.Runner,
rng *rand.Rand) (*artifact.Artifact, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/anaconda_ostree_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func NewAnacondaOSTreeInstaller(commit ostree.SourceSpec) *AnacondaOSTreeInstall
}
}

func (img *AnacondaOSTreeInstaller) InstantiateManifest(m *manifest.Manifest,
func (img *AnacondaOSTreeInstaller) InstantiateManifest(m manifest.Manifest,
repos []rpmmd.RepoConfig,
runner runner.Runner,
rng *rand.Rand) (*artifact.Artifact, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/anaconda_tar_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func NewAnacondaTarInstaller() *AnacondaTarInstaller {
}
}

func (img *AnacondaTarInstaller) InstantiateManifest(m *manifest.Manifest,
func (img *AnacondaTarInstaller) InstantiateManifest(m manifest.Manifest,
repos []rpmmd.RepoConfig,
runner runner.Runner,
rng *rand.Rand) (*artifact.Artifact, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewArchive() *Archive {
}
}

func (img *Archive) InstantiateManifest(m *manifest.Manifest,
func (img *Archive) InstantiateManifest(m manifest.Manifest,
repos []rpmmd.RepoConfig,
runner runner.Runner,
rng *rand.Rand) (*artifact.Artifact, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/bootc_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewBootcDiskImage(container container.SourceSpec) *BootcDiskImage {
}
}

func (img *BootcDiskImage) InstantiateManifestFromContainers(m *manifest.Manifest,
func (img *BootcDiskImage) InstantiateManifestFromContainers(m *manifest.IntManifest,
containers []container.SourceSpec,
runner runner.Runner,
rng *rand.Rand) error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/bootc_disk_legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewBootcLegacyDiskImage(real *BootcDiskImage) *BootcLegacyDiskImage {
}
}

func (img *BootcLegacyDiskImage) InstantiateManifestFromContainers(m *manifest.Manifest,
func (img *BootcLegacyDiskImage) InstantiateManifestFromContainers(m manifest.Manifest,
containers []container.SourceSpec,
runner runner.Runner,
rng *rand.Rand) error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/bootc_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func makeBootcDiskImageOsbuildManifest(t *testing.T, opts *bootcDiskImageTestOpt
img.Groups = opts.Groups
img.SELinux = opts.SELinux

m := &manifest.Manifest{}
m := &manifest.IntManifest{}
runi := &runner.Fedora{}
err := img.InstantiateManifestFromContainers(m, containers, runi, nil)
require.Nil(t, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewBaseContainer() *BaseContainer {
}
}

func (img *BaseContainer) InstantiateManifest(m *manifest.Manifest,
func (img *BaseContainer) InstantiateManifest(m manifest.Manifest,
repos []rpmmd.RepoConfig,
runner runner.Runner,
rng *rand.Rand) (*artifact.Artifact, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func NewDiskImage() *DiskImage {
}
}

func (img *DiskImage) InstantiateManifest(m *manifest.Manifest,
func (img *DiskImage) InstantiateManifest(m manifest.Manifest,
repos []rpmmd.RepoConfig,
runner runner.Runner,
rng *rand.Rand) (*artifact.Artifact, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/osbuild/images/pkg/runner"
)

func MockManifestNewBuild(new func(m *manifest.Manifest, runner runner.Runner, repos []rpmmd.RepoConfig, opts *manifest.BuildOptions) manifest.Build) (restore func()) {
func MockManifestNewBuild(new func(m manifest.Manifest, runner runner.Runner, repos []rpmmd.RepoConfig, opts *manifest.BuildOptions) manifest.Build) (restore func()) {
saved := manifestNewBuild
manifestNewBuild = new
return func() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

type ImageKind interface {
Name() string
InstantiateManifest(m *manifest.Manifest, repos []rpmmd.RepoConfig, runner runner.Runner, rng *rand.Rand) (*artifact.Artifact, error)
InstantiateManifest(m manifest.Manifest, repos []rpmmd.RepoConfig, runner runner.Runner, rng *rand.Rand) (*artifact.Artifact, error)
}

type Base struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/image/installer_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ func instantiateAndSerialize(t *testing.T, img image.ImageKind, packages map[str
/* #nosec G404 */
rng := rand.New(source)

mf := manifest.New()
_, err := img.InstantiateManifest(&mf, nil, &runner.CentOS{Version: 9}, rng)
mf := manifest.New(manifest.DISTRO_FEDORA)
_, err := img.InstantiateManifest(mf, nil, &runner.CentOS{Version: 9}, rng)
assert.NoError(t, err)

mfs, err := mf.Serialize(packages, containers, commits, nil)
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/ostree_archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func NewOSTreeArchive(ref string) *OSTreeArchive {
}
}

func (img *OSTreeArchive) InstantiateManifest(m *manifest.Manifest,
func (img *OSTreeArchive) InstantiateManifest(m manifest.Manifest,
repos []rpmmd.RepoConfig,
runner runner.Runner,
rng *rand.Rand) (*artifact.Artifact, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/ostree_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewOSTreeContainer(ref string) *OSTreeContainer {
}
}

func (img *OSTreeContainer) InstantiateManifest(m *manifest.Manifest,
func (img *OSTreeContainer) InstantiateManifest(m manifest.Manifest,
repos []rpmmd.RepoConfig,
runner runner.Runner,
rng *rand.Rand) (*artifact.Artifact, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/ostree_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func baseRawOstreeImage(img *OSTreeDiskImage, buildPipeline manifest.Build, opts
// replaced in testing
var manifestNewBuild = manifest.NewBuild

func (img *OSTreeDiskImage) InstantiateManifest(m *manifest.Manifest,
func (img *OSTreeDiskImage) InstantiateManifest(m manifest.Manifest,
repos []rpmmd.RepoConfig,
runner runner.Runner,
rng *rand.Rand) (*artifact.Artifact, error) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/image/ostree_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestOSTreeDiskImageManifestSetsContainerBuildable(t *testing.T) {
}

var buildOpts []*manifest.BuildOptions
restore := image.MockManifestNewBuild(func(m *manifest.Manifest, r runner.Runner, repos []rpmmd.RepoConfig, opts *manifest.BuildOptions) manifest.Build {
restore := image.MockManifestNewBuild(func(m manifest.Manifest, r runner.Runner, repos []rpmmd.RepoConfig, opts *manifest.BuildOptions) manifest.Build {
buildOpts = append(buildOpts, opts)
return manifest.NewBuild(m, r, repos, opts)
})
Expand All @@ -37,7 +37,7 @@ func TestOSTreeDiskImageManifestSetsContainerBuildable(t *testing.T) {
for _, containerBuildable := range []bool{true, false} {
buildOpts = nil

mf := manifest.New()
mf := manifest.New(manifest.DISTRO_FEDORA)
img := image.NewOSTreeDiskImageFromContainer(containerSource, ref)
require.NotNil(t, img)
img.Platform = &platform.X86{
Expand All @@ -51,7 +51,7 @@ func TestOSTreeDiskImageManifestSetsContainerBuildable(t *testing.T) {
img.OSName = "osname"
img.ContainerBuildable = containerBuildable

_, err := img.InstantiateManifest(&mf, repos, r, rng)
_, err := img.InstantiateManifest(mf, repos, r, rng)
require.Nil(t, err)
require.NotNil(t, img)

Expand Down
2 changes: 1 addition & 1 deletion pkg/image/ostree_simplified_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func NewOSTreeSimplifiedInstaller(rawImage *OSTreeDiskImage, installDevice strin
}
}

func (img *OSTreeSimplifiedInstaller) InstantiateManifest(m *manifest.Manifest,
func (img *OSTreeSimplifiedInstaller) InstantiateManifest(m manifest.Manifest,
repos []rpmmd.RepoConfig,
runner runner.Runner,
rng *rand.Rand) (*artifact.Artifact, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/manifest/anaconda_installer_iso_tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (

// newTestAnacondaISOTree returns a base AnacondaInstallerISOTree pipeline.
func newTestAnacondaISOTree() *AnacondaInstallerISOTree {
m := &Manifest{}
m := &IntManifest{}
runner := &runner.Linux{}
build := NewBuild(m, runner, nil, nil)

Expand Down
2 changes: 1 addition & 1 deletion pkg/manifest/anaconda_installer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func newAnacondaInstaller() *AnacondaInstaller {
m := &Manifest{}
m := &IntManifest{}
runner := &runner.Linux{}
build := NewBuild(m, runner, nil, nil)

Expand Down
6 changes: 3 additions & 3 deletions pkg/manifest/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
type Build interface {
Name() string
Checkpoint()
Manifest() *Manifest
Manifest() Manifest

addDependent(dep Pipeline)
}
Expand All @@ -45,7 +45,7 @@ type BuildOptions struct {

// NewBuild creates a new build pipeline from the repositories in repos
// and the specified packages.
func NewBuild(m *Manifest, runner runner.Runner, repos []rpmmd.RepoConfig, opts *BuildOptions) Build {
func NewBuild(m Manifest, runner runner.Runner, repos []rpmmd.RepoConfig, opts *BuildOptions) Build {
if opts == nil {
opts = &BuildOptions{}
}
Expand Down Expand Up @@ -164,7 +164,7 @@ type BuildrootFromContainer struct {

// NewBuildFromContainer creates a new build pipeline from the given
// containers specs
func NewBuildFromContainer(m *Manifest, runner runner.Runner, containerSources []container.SourceSpec, opts *BuildOptions) Build {
func NewBuildFromContainer(m Manifest, runner runner.Runner, containerSources []container.SourceSpec, opts *BuildOptions) Build {
if opts == nil {
opts = &BuildOptions{}
}
Expand Down
Loading
Loading