distro/fedoratest: create new testing distribution
The problem with the previous one was that we used artifical image types, architectures, and distribution but that is not possible any more because we don't want to use plain strings any more. This commit introduces a new testing distro which uses proper, existing types.
This commit is contained in:
parent
eb6c0f6fce
commit
73994eb06d
1 changed files with 62 additions and 0 deletions
62
internal/distro/fedoratest/distro.go
Normal file
62
internal/distro/fedoratest/distro.go
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
package fedoratest
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/pipeline"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
)
|
||||
|
||||
type FedoraTestDistro struct{}
|
||||
|
||||
func New() *FedoraTestDistro {
|
||||
return &FedoraTestDistro{}
|
||||
}
|
||||
|
||||
func (d *FedoraTestDistro) Name() string {
|
||||
return "fedora-30"
|
||||
}
|
||||
|
||||
func (d *FedoraTestDistro) Distribution() common.Distribution {
|
||||
return common.Fedora30
|
||||
}
|
||||
|
||||
func (d *FedoraTestDistro) Repositories(arch string) []rpmmd.RepoConfig {
|
||||
return []rpmmd.RepoConfig{
|
||||
{
|
||||
Id: "test-id",
|
||||
Name: "Test Name",
|
||||
BaseURL: "http://example.com/test/os/" + arch,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (d *FedoraTestDistro) ListOutputFormats() []string {
|
||||
return []string{"qcow2"}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *FedoraTestDistro) GetSizeForOutputType(outputFormat string, size uint64) uint64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (d *FedoraTestDistro) Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, checksums map[string]string, outputArch, outputFormat string, size uint64) (*pipeline.Pipeline, error) {
|
||||
if outputFormat == "qcow2" && outputArch == "x86_64" {
|
||||
return &pipeline.Pipeline{}, nil
|
||||
} else {
|
||||
return nil, errors.New("invalid output format or arch: " + outputFormat + " @ " + outputArch)
|
||||
}
|
||||
}
|
||||
|
||||
func (d *FedoraTestDistro) Runner() string {
|
||||
return "org.osbuild.test"
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue