manifest: implement serializeStart() for ostree pipelines
Pipelines that don't require packages didn't need to implement the serializeStart() method, but now we need to set the resolved ostree commit spec when a pipelines requires it.
This commit is contained in:
parent
89a398371d
commit
48ee694ff3
3 changed files with 52 additions and 3 deletions
|
|
@ -4,9 +4,11 @@ import (
|
|||
"fmt"
|
||||
"path"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/container"
|
||||
"github.com/osbuild/osbuild-composer/internal/disk"
|
||||
"github.com/osbuild/osbuild-composer/internal/osbuild"
|
||||
"github.com/osbuild/osbuild-composer/internal/ostree"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/users"
|
||||
)
|
||||
|
||||
|
|
@ -73,7 +75,6 @@ func NewAnacondaISOTree(m *Manifest,
|
|||
return p
|
||||
}
|
||||
|
||||
// Return the ostree commit URL and checksum that will be included in this
|
||||
func (p *AnacondaISOTree) getOSTreeCommits() []ostree.CommitSpec {
|
||||
if p.OSTree == nil {
|
||||
return nil
|
||||
|
|
@ -100,6 +101,23 @@ func (p *AnacondaISOTree) getBuildPackages() []string {
|
|||
return packages
|
||||
}
|
||||
|
||||
func (p *AnacondaISOTree) serializeStart(_ []rpmmd.PackageSpec, _ []container.Spec, commits []ostree.CommitSpec) {
|
||||
if len(commits) == 0 {
|
||||
// nothing to do
|
||||
return
|
||||
}
|
||||
|
||||
if len(commits) > 1 {
|
||||
panic("pipeline supports at most one ostree commit")
|
||||
}
|
||||
|
||||
p.OSTree = &commits[0]
|
||||
}
|
||||
|
||||
func (p *AnacondaISOTree) serializeEnd() {
|
||||
p.OSTree = nil
|
||||
}
|
||||
|
||||
func (p *AnacondaISOTree) serialize() osbuild.Pipeline {
|
||||
// We need one of two payloads
|
||||
if p.OSTree == nil && p.OSPipeline == nil {
|
||||
|
|
|
|||
|
|
@ -147,11 +147,14 @@ type OS struct {
|
|||
// Partition table, if nil the tree cannot be put on a partitioned disk
|
||||
PartitionTable *disk.PartitionTable
|
||||
|
||||
// content-related fields
|
||||
repos []rpmmd.RepoConfig
|
||||
packageSpecs []rpmmd.PackageSpec
|
||||
containerSpecs []container.Spec
|
||||
platform platform.Platform
|
||||
kernelVer string
|
||||
ostreeSpecs []ostree.CommitSpec
|
||||
|
||||
platform platform.Platform
|
||||
kernelVer string
|
||||
|
||||
// NoBLS configures the image bootloader with traditional menu entries
|
||||
// instead of BLS. Required for legacy systems like RHEL 7.
|
||||
|
|
@ -298,6 +301,7 @@ func (p *OS) serializeStart(packages []rpmmd.PackageSpec, containers []container
|
|||
|
||||
p.packageSpecs = packages
|
||||
p.containerSpecs = containers
|
||||
p.ostreeSpecs = commits
|
||||
|
||||
if p.KernelName != "" {
|
||||
p.kernelVer = rpmmd.GetVerStrFromPackageSpecListPanic(p.packageSpecs, p.KernelName)
|
||||
|
|
@ -311,6 +315,7 @@ func (p *OS) serializeEnd() {
|
|||
p.kernelVer = ""
|
||||
p.packageSpecs = nil
|
||||
p.containerSpecs = nil
|
||||
p.ostreeSpecs = nil
|
||||
}
|
||||
|
||||
func (p *OS) serialize() osbuild.Pipeline {
|
||||
|
|
|
|||
|
|
@ -5,11 +5,13 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/container"
|
||||
"github.com/osbuild/osbuild-composer/internal/disk"
|
||||
"github.com/osbuild/osbuild-composer/internal/fsnode"
|
||||
"github.com/osbuild/osbuild-composer/internal/osbuild"
|
||||
"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/users"
|
||||
)
|
||||
|
||||
|
|
@ -81,7 +83,31 @@ func (p *OSTreeDeployment) getOSTreeCommits() []ostree.CommitSpec {
|
|||
return []ostree.CommitSpec{p.commit}
|
||||
}
|
||||
|
||||
func (p *OSTreeDeployment) serializeStart(packages []rpmmd.PackageSpec, containers []container.Spec, commits []ostree.CommitSpec) {
|
||||
if p.commit.Ref != "" {
|
||||
panic("double call to serializeStart()")
|
||||
}
|
||||
|
||||
if len(commits) != 1 {
|
||||
panic("pipeline requires exactly one ostree commit")
|
||||
}
|
||||
|
||||
p.commit = commits[0]
|
||||
}
|
||||
|
||||
func (p *OSTreeDeployment) serializeEnd() {
|
||||
if p.commit.Ref == "" {
|
||||
panic("serializeEnd() call when serialization not in progress")
|
||||
}
|
||||
|
||||
p.commit = ostree.CommitSpec{}
|
||||
}
|
||||
|
||||
func (p *OSTreeDeployment) serialize() osbuild.Pipeline {
|
||||
if p.commit.Ref == "" {
|
||||
panic("serialization not started")
|
||||
}
|
||||
|
||||
const repoPath = "/ostree/repo"
|
||||
|
||||
pipeline := p.Base.serialize()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue