debian-forge-composer/internal/distro/fedoratest/distro.go
Tom Gundersen 87b0bb6e5d distro: mass cleanup
Delete unused methods and make types and fields private where
possible. Some code is moved around, but apart from that there
is no change in behavior.

The naming of the distros were moved back into the distro
packages as the common types now only had one user, and this
allowed us to drop some redundant error checking.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-24 14:13:03 +01:00

110 lines
2.4 KiB
Go

package fedoratest
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"
)
const name = "fedora-30"
const modulePlatformID = "platform:f30"
type FedoraTestDistro struct{}
type fedoraTestDistroArch struct {
name string
distro *FedoraTestDistro
}
type fedoraTestDistroImageType struct {
name string
arch *fedoraTestDistroArch
}
func (d *FedoraTestDistro) GetArch(arch string) (distro.Arch, error) {
if arch != "x86_64" {
return nil, errors.New("invalid architecture: " + arch)
}
return &fedoraTestDistroArch{
name: arch,
distro: d,
}, nil
}
func (a *fedoraTestDistroArch) Name() string {
return a.name
}
func (a *fedoraTestDistroArch) ListImageTypes() []string {
return []string{"qcow2"}
}
func (a *fedoraTestDistroArch) GetImageType(imageType string) (distro.ImageType, error) {
if imageType != "qcow2" {
return nil, errors.New("invalid image type: " + imageType)
}
return &fedoraTestDistroImageType{
name: imageType,
arch: a,
}, nil
}
func (t *fedoraTestDistroImageType) Name() string {
return t.name
}
func (t *fedoraTestDistroImageType) Filename() string {
return "test.img"
}
func (t *fedoraTestDistroImageType) MIMEType() string {
return "application/x-test"
}
func (t *fedoraTestDistroImageType) Size(size uint64) uint64 {
return size
}
func (t *fedoraTestDistroImageType) BasePackages() ([]string, []string) {
return nil, nil
}
func (t *fedoraTestDistroImageType) BuildPackages() []string {
return nil
}
func (t *fedoraTestDistroImageType) Manifest(c *blueprint.Customizations,
repos []rpmmd.RepoConfig,
packageSpecs,
buildPackageSpecs []rpmmd.PackageSpec,
size uint64) (*osbuild.Manifest, error) {
return &osbuild.Manifest{
Pipeline: osbuild.Pipeline{},
Sources: osbuild.Sources{},
}, nil
}
func New() *FedoraTestDistro {
return &FedoraTestDistro{}
}
func (d *FedoraTestDistro) Name() string {
return name
}
func (d *FedoraTestDistro) ModulePlatformID() string {
return modulePlatformID
}
func (d *FedoraTestDistro) FilenameFromType(outputFormat string) (string, string, error) {
if outputFormat == "qcow2" {
return "test.img", "application/x-test", nil
} else {
return "", "", errors.New("invalid output format: " + outputFormat)
}
}