In the OS pipeline, the parent configuration was used to detect if the pipeline's setup was meant for an ostree commit or not. Also, the pipeline used a new type to specify the ostree parameters. - Use the ostree.CommitSpec for the parent configuration. - Add a new attribute, OSTreeRef, that defines the ref for the ostree commit being built. An empty string indicates that the tree is not for an ostree commit. Additionally, in the ImageKind configurations for the ostree archive and container, separate the ostree ref from the parent spec, make the parent spec optional (pointer) and the ostree ref mandatory, by requiring it in the constructor of the ImageKind.
57 lines
1.8 KiB
Go
57 lines
1.8 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 *ostree.CommitSpec
|
|
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
|
|
}
|