weldr: get repositories from distro
Make distros export repository information and use those in the weldr API. This means that repos are only specified once and that the API returns the right packages when we allow different distros.
This commit is contained in:
parent
1dac0a03d2
commit
b911d0b928
6 changed files with 94 additions and 29 deletions
|
|
@ -10,9 +10,14 @@ import (
|
|||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/pipeline"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
)
|
||||
|
||||
type Distro interface {
|
||||
// Returns a list of repositories from which this distribution gets its
|
||||
// content.
|
||||
Repositories() []rpmmd.RepoConfig
|
||||
|
||||
// Returns a sorted list of the output formats this distro supports.
|
||||
ListOutputFormats() []string
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/pipeline"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
)
|
||||
|
||||
type Fedora30 struct {
|
||||
|
|
@ -34,6 +35,16 @@ func init() {
|
|||
})
|
||||
}
|
||||
|
||||
func (f *Fedora30) Repositories() []rpmmd.RepoConfig {
|
||||
return []rpmmd.RepoConfig{
|
||||
{
|
||||
Id: "fedora",
|
||||
Name: "Fedora 30",
|
||||
Metalink: "https://mirrors.fedoraproject.org/metalink?repo=fedora-30&arch=x86_64",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// ListOutputFormats returns a sorted list of the supported output formats
|
||||
func (f *Fedora30) ListOutputFormats() []string {
|
||||
formats := make([]string, 0, len(f.outputs))
|
||||
|
|
|
|||
36
internal/distro/test/distro.go
Normal file
36
internal/distro/test/distro.go
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/pipeline"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
)
|
||||
|
||||
type TestDistro struct{}
|
||||
|
||||
func init() {
|
||||
distro.Register("test", &TestDistro{})
|
||||
}
|
||||
|
||||
func (d *TestDistro) Repositories() []rpmmd.RepoConfig {
|
||||
return []rpmmd.RepoConfig{
|
||||
{
|
||||
Id: "test",
|
||||
Name: "Test",
|
||||
BaseURL: "http://example.com/test/os",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (d *TestDistro) ListOutputFormats() []string {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
func (d *TestDistro) FilenameFromType(outputFormat string) (string, string, error) {
|
||||
return "", "", &distro.InvalidOutputFormatError{outputFormat}
|
||||
}
|
||||
|
||||
func (d *TestDistro) Pipeline(b *blueprint.Blueprint, outputFormat string) (*pipeline.Pipeline, error) {
|
||||
return nil, &distro.InvalidOutputFormatError{outputFormat}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue