When generating an osbuild manifest for an image type, we take a customizations struct, which specifies the image-type-independent customizations to apply. We also take the size argument, which is specific to the image build and not part of the blueprint. Introduce a new argument ImageOptions, which for now just wraps the size argument. These options are specific to the image build/type, and therefore does not belong with the other customizations. For now this is a non-functional change, but follow-up commits will introduce more types of image options. Signed-off-by: Tom Gundersen <teg@jklm.no>
102 lines
2.2 KiB
Go
102 lines
2.2 KiB
Go
package test_distro
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
|
"github.com/osbuild/osbuild-composer/internal/distro"
|
|
"github.com/osbuild/osbuild-composer/internal/osbuild"
|
|
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
|
)
|
|
|
|
type TestDistro struct{}
|
|
type TestArch struct{}
|
|
type TestImageType struct{}
|
|
|
|
const name = "test-distro"
|
|
const modulePlatformID = "platform:test"
|
|
|
|
func (d *TestDistro) ListArches() []string {
|
|
return []string{"test_arch"}
|
|
}
|
|
|
|
func (a *TestArch) Distro() distro.Distro {
|
|
return &TestDistro{}
|
|
}
|
|
|
|
func (t *TestImageType) Arch() distro.Arch {
|
|
return &TestArch{}
|
|
}
|
|
|
|
func (d *TestDistro) GetArch(arch string) (distro.Arch, error) {
|
|
if arch != "test_arch" {
|
|
return nil, errors.New("invalid arch: " + arch)
|
|
}
|
|
return &TestArch{}, nil
|
|
}
|
|
|
|
func (a *TestArch) Name() string {
|
|
return "test_arch"
|
|
}
|
|
|
|
func (a *TestArch) ListImageTypes() []string {
|
|
return []string{"test_type"}
|
|
}
|
|
|
|
func (a *TestArch) GetImageType(imageType string) (distro.ImageType, error) {
|
|
if imageType != "test_type" {
|
|
return nil, errors.New("invalid image type: " + imageType)
|
|
}
|
|
return &TestImageType{}, nil
|
|
}
|
|
|
|
func (t *TestImageType) Name() string {
|
|
return "test_type"
|
|
}
|
|
|
|
func (t *TestImageType) Filename() string {
|
|
return "test.img"
|
|
}
|
|
|
|
func (t *TestImageType) MIMEType() string {
|
|
return "application/x-test"
|
|
}
|
|
|
|
func (t *TestImageType) Size(size uint64) uint64 {
|
|
return 0
|
|
}
|
|
|
|
func (t *TestImageType) BasePackages() ([]string, []string) {
|
|
return nil, nil
|
|
}
|
|
|
|
func (t *TestImageType) BuildPackages() []string {
|
|
return nil
|
|
}
|
|
|
|
func (t *TestImageType) Manifest(b *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec) (*osbuild.Manifest, error) {
|
|
return &osbuild.Manifest{
|
|
Sources: osbuild.Sources{},
|
|
Pipeline: osbuild.Pipeline{},
|
|
}, nil
|
|
}
|
|
|
|
func New() *TestDistro {
|
|
return &TestDistro{}
|
|
}
|
|
|
|
func (d *TestDistro) Name() string {
|
|
return name
|
|
}
|
|
|
|
func (d *TestDistro) ModulePlatformID() string {
|
|
return modulePlatformID
|
|
}
|
|
|
|
func (d *TestDistro) FilenameFromType(outputFormat string) (string, string, error) {
|
|
if outputFormat == "test_format" {
|
|
return "test.img", "application/x-test", nil
|
|
}
|
|
|
|
return "", "", errors.New("invalid output format: " + outputFormat)
|
|
}
|