Skip to content

Commit

Permalink
manifest: use NewContainersInputForSingleSource() in BuildrootFromCon…
Browse files Browse the repository at this point in the history
…tainer

A BuildrootFromContainer needs exactly one container as input. Use
this fact when creating the image inputs for the NewContainerDeployStage()
when serializing. This avoids having to know about details about
local/non-local storage at the manifest level.
  • Loading branch information
mvo5 authored and ondrejbudai committed Feb 28, 2024
1 parent c100aeb commit 4835faf
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions pkg/manifest/build.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package manifest

import (
"fmt"

"github.com/osbuild/images/pkg/container"
"github.com/osbuild/images/pkg/osbuild"
"github.com/osbuild/images/pkg/ostree"
Expand Down Expand Up @@ -225,28 +227,23 @@ func (p *BuildrootFromContainer) serialize() osbuild.Pipeline {
if len(p.containerSpecs) == 0 {
panic("serialization not started")
}
if len(p.containerSpecs) != 1 {
panic(fmt.Sprintf("BuildrootFromContainer expectes exactly one container input, got: %v", p.containerSpecs))
}

pipeline := p.Base.serialize()
pipeline.Runner = p.runner.String()

images := osbuild.NewContainersInputForSources(p.containerSpecs)
image := osbuild.NewContainersInputForSingleSource(p.containerSpecs[0])
options := &osbuild.ContainerDeployOptions{
Exclude: []string{"/sysroot"},
}
if len(images.References) > 0 {
stage, err := osbuild.NewContainerDeployStage(images, options)
if err != nil {
panic(err)
}
pipeline.AddStage(stage)
}
localImages := osbuild.NewLocalContainersInputForSources(p.containerSpecs)
if len(localImages.References) > 0 {
stage, err := osbuild.NewContainerDeployStage(localImages, options)
if err != nil {
panic(err)
}
pipeline.AddStage(stage)

stage, err := osbuild.NewContainerDeployStage(image, options)
if err != nil {
panic(err)
}
pipeline.AddStage(stage)
pipeline.AddStage(osbuild.NewSELinuxStage(
&osbuild.SELinuxStageOptions{
FileContexts: "etc/selinux/targeted/contexts/files/file_contexts",
Expand Down

0 comments on commit 4835faf

Please sign in to comment.