runner: introduce runner abstraction

For now all it does is represent the name of the runner and what requirements
it has of the build pipeline.

Move some package definitions from the runner package set to where it belongs.
This commit is contained in:
Tom Gundersen 2022-07-08 01:34:38 +01:00
parent 33fe2da25c
commit 529bc803db
22 changed files with 101 additions and 40 deletions

View file

@ -14,13 +14,14 @@ import (
"github.com/osbuild/osbuild-composer/internal/distroregistry"
"github.com/osbuild/osbuild-composer/internal/manifest"
"github.com/osbuild/osbuild-composer/internal/rpmmd"
"github.com/osbuild/osbuild-composer/internal/runner"
)
var ImageTypes = make(map[string]ImageType)
type ImageType interface {
Name() string
InstantiateManifest(m *manifest.Manifest, repos []rpmmd.RepoConfig, runner string) error
InstantiateManifest(m *manifest.Manifest, repos []rpmmd.RepoConfig, runner runner.Runner) error
GetExports() []string
GetCheckpoints() []string
}

View file

@ -4,6 +4,7 @@ import (
"github.com/osbuild/osbuild-composer/internal/manifest"
"github.com/osbuild/osbuild-composer/internal/platform"
"github.com/osbuild/osbuild-composer/internal/rpmmd"
"github.com/osbuild/osbuild-composer/internal/runner"
)
func init() {
@ -35,7 +36,7 @@ func (img *MyImage) Name() string {
// Return nil when you are done, or an error if something
// went wrong. Your manifest will be streamed to osbuild
// for building.
func (img *MyImage) InstantiateManifest(m *manifest.Manifest, repos []rpmmd.RepoConfig, runner string) error {
func (img *MyImage) InstantiateManifest(m *manifest.Manifest, repos []rpmmd.RepoConfig, runner runner.Runner) error {
// Let's create a simple OCI container!
// configure a build pipeline

View file

@ -10,6 +10,7 @@ import (
"github.com/osbuild/osbuild-composer/internal/manifest"
"github.com/osbuild/osbuild-composer/internal/osbuild2"
"github.com/osbuild/osbuild-composer/internal/rpmmd"
"github.com/osbuild/osbuild-composer/internal/runner"
)
func RunPlayground(img ImageType, d distro.Distro, arch distro.Arch, repos map[string][]rpmmd.RepoConfig, state_dir string) {
@ -22,8 +23,8 @@ func RunPlayground(img ImageType, d distro.Distro, arch distro.Arch, repos map[s
manifest := manifest.New()
// TODO: figure out the runner situation
err := img.InstantiateManifest(&manifest, repos[arch.Name()], "org.osbuild.fedora36")
// TODO: query distro for runner
err := img.InstantiateManifest(&manifest, repos[arch.Name()], &runner.Fedora{Version: 36})
if err != nil {
panic("InstantiateManifest() failed: " + err.Error())
}