manifest: make ostree commit spec mandatory in the OSTreeInstaller

Make the ostree commit spec mandatory in the OSTreeInstaller ImageKind.
The installer image type is not just for ostree types so make the ostree
parameters optional for the ISOTree Pipeline.

Use the ostree.CommitSpec to specify commits parameters.
This commit is contained in:
Achilleas Koutsou 2022-09-30 16:29:46 +02:00 committed by Tomáš Hozza
parent 711fc697e4
commit 5f98d7082c
3 changed files with 27 additions and 26 deletions

View file

@ -243,7 +243,12 @@ func iotInstallerImage(workload workload.Workload,
d := t.arch.distro
img := image.NewOSTreeInstaller()
commit := ostree.CommitSpec{
Ref: options.OSTree.ImageRef,
URL: options.OSTree.URL,
Checksum: options.OSTree.FetchChecksum,
}
img := image.NewOSTreeInstaller(commit)
img.Platform = t.platform
img.ExtraBasePackages = packageSets[installerPkgsKey]
@ -257,10 +262,6 @@ func iotInstallerImage(workload workload.Workload,
img.OSVersion = d.osVersion
img.Release = "202010217.n.0" // ???
img.OSTreeURL = options.OSTree.URL
img.OSTreeRef = options.OSTree.ImageRef
img.OSTreeCommit = options.OSTree.FetchChecksum
img.Filename = t.Filename()
return img, nil

View file

@ -8,6 +8,7 @@ import (
"github.com/osbuild/osbuild-composer/internal/common"
"github.com/osbuild/osbuild-composer/internal/disk"
"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"
@ -28,16 +29,15 @@ type OSTreeInstaller struct {
OSVersion string
Release string
OSTreeURL string
OSTreeRef string
OSTreeCommit string
Commit ostree.CommitSpec
Filename string
}
func NewOSTreeInstaller() *OSTreeInstaller {
func NewOSTreeInstaller(commit ostree.CommitSpec) *OSTreeInstaller {
return &OSTreeInstaller{
Base: NewBase("ostree-installer"),
Base: NewBase("ostree-installer"),
Commit: commit,
}
}
@ -94,9 +94,6 @@ func (img *OSTreeInstaller) InstantiateManifest(m *manifest.Manifest,
anacondaPipeline,
rootfsImagePipeline,
bootTreePipeline,
img.OSTreeCommit,
img.OSTreeURL,
img.OSTreeRef,
isoLabel)
isoTreePipeline.PartitionTable = rootfsPartitionTable
isoTreePipeline.Release = img.Release
@ -105,6 +102,8 @@ func (img *OSTreeInstaller) InstantiateManifest(m *manifest.Manifest,
isoTreePipeline.Groups = img.Groups
isoTreePipeline.KSPath = "/ostree.ks"
isoTreePipeline.OSTree = &img.Commit
isoPipeline := manifest.NewISO(m, buildPipeline, isoTreePipeline)
isoPipeline.Filename = img.Filename
isoPipeline.ISOLinux = true

View file

@ -31,7 +31,7 @@ type ISOTree struct {
KSPath string
isoLabel string
ostree ostree.RequestParams
OSTree *ostree.CommitSpec
}
func NewISOTree(m *Manifest,
@ -39,9 +39,6 @@ func NewISOTree(m *Manifest,
anacondaPipeline *Anaconda,
rootfsPipeline *ISORootfsImg,
bootTreePipeline *EFIBootTree,
ostreeCommit,
ostreeURL,
ostreeRef,
isoLabel string) *ISOTree {
p := &ISOTree{
@ -50,11 +47,6 @@ func NewISOTree(m *Manifest,
rootfsPipeline: rootfsPipeline,
bootTreePipeline: bootTreePipeline,
isoLabel: isoLabel,
ostree: ostree.RequestParams{
Parent: ostreeCommit,
URL: ostreeURL,
Ref: ostreeRef,
},
}
buildPipeline.addDependent(p)
if anacondaPipeline.Base.manifest != m {
@ -65,10 +57,16 @@ func NewISOTree(m *Manifest,
}
func (p *ISOTree) getOSTreeCommits() []osTreeCommit {
var checksum, url string
if p.OSTree != nil {
checksum = p.OSTree.Checksum
url = p.OSTree.URL
}
return []osTreeCommit{
{
checksum: p.ostree.Parent,
url: p.ostree.URL,
checksum: checksum,
url: url,
},
}
}
@ -166,7 +164,10 @@ func (p *ISOTree) serialize() osbuild.Pipeline {
copyInputs,
))
kickstartOptions, err := osbuild.NewKickstartStageOptions(p.KSPath, "", p.Users, p.Groups, makeISORootPath(ostreeRepoPath), p.ostree.Ref, p.OSName)
if p.OSTree == nil {
panic("missing ostree parameters in ISO tree pipeline")
}
kickstartOptions, err := osbuild.NewKickstartStageOptions(p.KSPath, "", p.Users, p.Groups, makeISORootPath(ostreeRepoPath), p.OSTree.Ref, p.OSName)
if err != nil {
panic("password encryption failed")
}
@ -174,7 +175,7 @@ func (p *ISOTree) serialize() osbuild.Pipeline {
pipeline.AddStage(osbuild.NewOSTreeInitStage(&osbuild.OSTreeInitStageOptions{Path: ostreeRepoPath}))
pipeline.AddStage(osbuild.NewOSTreePullStage(
&osbuild.OSTreePullStageOptions{Repo: ostreeRepoPath},
osbuild.NewOstreePullStageInputs("org.osbuild.source", p.ostree.Parent, p.ostree.Ref),
osbuild.NewOstreePullStageInputs("org.osbuild.source", p.OSTree.Checksum, p.OSTree.Ref),
))
pipeline.AddStage(osbuild.NewKickstartStage(kickstartOptions))