debian-forge-composer/internal/image/ostree_archive.go
Achilleas Koutsou 966aec464a image: add ostree commit source when initialising manifest
When initialising a manifest, use the ostree commit source spec only.
Then, when serialising, use the resolved ostree commit.
This is the same process we use for the other content types, packages
and containers.

Two new functions are defined in the distros to handle resolving the
ostree options: one for creating the parent commit source spec and image
ref for image types that have an optional parent commit (ostree commits
and containers) and one for creating the payload commit source spec for
image types that require an ostree payload (ostree raw images and
installers).
2023-06-14 11:19:29 +02:00

63 lines
1.9 KiB
Go

package image
import (
"math/rand"
"github.com/osbuild/osbuild-composer/internal/artifact"
"github.com/osbuild/osbuild-composer/internal/environment"
"github.com/osbuild/osbuild-composer/internal/manifest"
"github.com/osbuild/osbuild-composer/internal/ostree"
"github.com/osbuild/osbuild-composer/internal/platform"
"github.com/osbuild/osbuild-composer/internal/rpmmd"
"github.com/osbuild/osbuild-composer/internal/runner"
"github.com/osbuild/osbuild-composer/internal/workload"
)
type OSTreeArchive struct {
Base
Platform platform.Platform
OSCustomizations manifest.OSCustomizations
Environment environment.Environment
Workload workload.Workload
// OSTreeParent specifies the source for an optional parent commit for the
// new commit being built.
OSTreeParent *ostree.SourceSpec
// OSTreeRef is the ref of the commit that will be built.
OSTreeRef string
OSVersion string
Filename string
}
func NewOSTreeArchive(ref string) *OSTreeArchive {
return &OSTreeArchive{
Base: NewBase("ostree-archive"),
OSTreeRef: ref,
}
}
func (img *OSTreeArchive) InstantiateManifest(m *manifest.Manifest,
repos []rpmmd.RepoConfig,
runner runner.Runner,
rng *rand.Rand) (*artifact.Artifact, error) {
buildPipeline := manifest.NewBuild(m, runner, repos)
buildPipeline.Checkpoint()
osPipeline := manifest.NewOS(m, buildPipeline, img.Platform, repos)
osPipeline.OSCustomizations = img.OSCustomizations
osPipeline.Environment = img.Environment
osPipeline.Workload = img.Workload
osPipeline.OSTreeParent = img.OSTreeParent
osPipeline.OSTreeRef = img.OSTreeRef
ostreeCommitPipeline := manifest.NewOSTreeCommit(m, buildPipeline, osPipeline, img.OSTreeRef)
ostreeCommitPipeline.OSVersion = img.OSVersion
tarPipeline := manifest.NewTar(m, buildPipeline, &ostreeCommitPipeline.Base, "commit-archive")
tarPipeline.Filename = img.Filename
artifact := tarPipeline.Export()
return artifact, nil
}