image: add image kind abstraction

This abstracts away the manifest instantiation. The idea is that we define one
of these image kind types to represent a group of image types that are
sufficiently similar. Each image kind will have a struct with with all the
properties that can be customised for the image and a function to turn that into
an actual manifest. This is similar to how distro/fedora/manifest.go and
cmd/osbuild-playground works today, and aspires to move these closer together
and to eventually make the distro definitions simpler.

For now cmd/osbuild-playground is moved over to using the new abstraction.
This commit is contained in:
Tom Gundersen 2022-07-10 13:45:24 +01:00 committed by Christian Kellner
parent ce40e1d810
commit 5a15608c89
5 changed files with 63 additions and 51 deletions

29
internal/image/image.go Normal file
View file

@ -0,0 +1,29 @@
package image
import (
"math/rand"
"github.com/osbuild/osbuild-composer/internal/artifact"
"github.com/osbuild/osbuild-composer/internal/manifest"
"github.com/osbuild/osbuild-composer/internal/rpmmd"
"github.com/osbuild/osbuild-composer/internal/runner"
)
type ImageKind interface {
Name() string
InstantiateManifest(m *manifest.Manifest, repos []rpmmd.RepoConfig, runner runner.Runner, rng *rand.Rand) (*artifact.Artifact, error)
}
type Base struct {
name string
}
func (img Base) Name() string {
return img.name
}
func NewBase(name string) Base {
return Base{
name: name,
}
}