manifest: collect container and ostree source specs

Much like the GetPackageSetChains() manifest method, these two new
methods collect the container and ostree source specifications from the
pipelines that support them.  Currently, only one pipeline per manifest
contains references to containers or ostree commits, but we collect them
in a map, keyed by the pipeline name, both for consistency with the
package sets and for any potential future changes that may require
differentiating which pipeline a content source belongs to.
This commit is contained in:
Achilleas Koutsou 2023-05-15 20:09:11 +02:00 committed by Simon de Vlieger
parent fd7d1d45a8
commit 955e343122
6 changed files with 41 additions and 2 deletions

View file

@ -325,6 +325,8 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
}
manifest.Content.PackageSets = manifest.GetPackageSetChains()
manifest.Content.Containers = manifest.GetContainerSourceSpecs()
manifest.Content.OSTreeCommits = manifest.GetOSTreeSourceSpecs()
return &manifest, warnings, err
}

View file

@ -219,6 +219,8 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
}
manifest.Content.PackageSets = overridePackageNamesInSets(manifest.GetPackageSetChains())
manifest.Content.Containers = manifest.GetContainerSourceSpecs()
manifest.Content.OSTreeCommits = manifest.GetOSTreeSourceSpecs()
return &manifest, warnings, err
}

View file

@ -253,6 +253,8 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
}
manifest.Content.PackageSets = overridePackageNamesInSets(manifest.GetPackageSetChains())
manifest.Content.Containers = manifest.GetContainerSourceSpecs()
manifest.Content.OSTreeCommits = manifest.GetOSTreeSourceSpecs()
return &manifest, warnings, err
}

View file

@ -253,6 +253,8 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
}
manifest.Content.PackageSets = manifest.GetPackageSetChains()
manifest.Content.Containers = manifest.GetContainerSourceSpecs()
manifest.Content.OSTreeCommits = manifest.GetOSTreeSourceSpecs()
return &manifest, warnings, err
}

View file

@ -71,11 +71,11 @@ type Content struct {
PackageSets map[string][]rpmmd.PackageSet
// Containers are source specifications for containers to embed in the image.
Containers []container.SourceSpec
Containers map[string][]container.SourceSpec
// OSTreeCommits are source specifications for ostree commits to embed in
// the image or use as parent commits when building a new one.
OSTreeCommits []ostree.SourceSpec
OSTreeCommits map[string][]ostree.SourceSpec
}
func New() Manifest {
@ -105,6 +105,32 @@ func (m Manifest) GetPackageSetChains() map[string][]rpmmd.PackageSet {
return chains
}
func (m Manifest) GetContainerSourceSpecs() map[string][]container.SourceSpec {
// Containers should only appear in the payload pipeline.
// Let's iterate over all pipelines to avoid assuming pipeline names, but
// return all the specs as a single slice.
containerSpecs := make(map[string][]container.SourceSpec)
for _, pipeline := range m.pipelines {
if containers := pipeline.getContainerSources(); len(containers) > 0 {
containerSpecs[pipeline.Name()] = containers
}
}
return containerSpecs
}
func (m Manifest) GetOSTreeSourceSpecs() map[string][]ostree.SourceSpec {
// OSTree commits should only appear in one pipeline.
// Let's iterate over all pipelines to avoid assuming pipeline names, but
// return all the specs as a single slice if there are multiple.
ostreeSpecs := make(map[string][]ostree.SourceSpec)
for _, pipeline := range m.pipelines {
if commits := pipeline.getOSTreeCommitSources(); len(commits) > 0 {
ostreeSpecs[pipeline.Name()] = commits
}
}
return ostreeSpecs
}
func (m Manifest) Serialize(packageSets map[string][]rpmmd.PackageSpec) (OSBuildManifest, error) {
pipelines := make([]osbuild.Pipeline, 0)
packages := make([]rpmmd.PackageSpec, 0)

View file

@ -241,6 +241,10 @@ func (p *OS) getPackageSetChain() []rpmmd.PackageSet {
return chain
}
func (p *OS) getContainerSources() []container.SourceSpec {
return p.OSCustomizations.Containers
}
func (p *OS) getBuildPackages() []string {
packages := p.platform.GetBuildPackages()
if p.PartitionTable != nil {
@ -301,6 +305,7 @@ func (p *OS) serializeEnd() {
}
p.kernelVer = ""
p.packageSpecs = nil
p.containerSpecs = nil
}
func (p *OS) serialize() osbuild.Pipeline {