Skip to content

Commit

Permalink
manifest: add stage for local containers
Browse files Browse the repository at this point in the history
Currently `osbuild` doesn't support adding multiple input types for containers.
We can workaround this by adding a stage per input type, if multiple input types
exist.
  • Loading branch information
kingsleyzissou committed Feb 20, 2024
1 parent eed1ba5 commit 8204aab
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
7 changes: 6 additions & 1 deletion pkg/manifest/anaconda_installer_iso_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,12 @@ func (p *AnacondaInstallerISOTree) ostreeCommitStages() []*osbuild.Stage {
func (p *AnacondaInstallerISOTree) ostreeContainerStages() []*osbuild.Stage {
stages := make([]*osbuild.Stage, 0)

images := osbuild.NewContainersInputForSources([]container.Spec{*p.containerSpec})
var images osbuild.ContainersInput
if p.containerSpec.LocalStorage {
images = osbuild.NewLocalContainersInputForSources([]container.Spec{*p.containerSpec})
} else {
images = osbuild.NewContainersInputForSources([]container.Spec{*p.containerSpec})
}

stages = append(stages, osbuild.NewMkdirStage(&osbuild.MkdirStageOptions{
Paths: []osbuild.MkdirStagePath{
Expand Down
1 change: 1 addition & 0 deletions pkg/manifest/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ func (p *BuildrootFromContainer) serialize() osbuild.Pipeline {
pipeline := p.Base.serialize()
pipeline.Runner = p.runner.String()

// TODO: do we want to adding local containers here too?
inputs := osbuild.NewContainersInputForSources(p.containerSpecs)
options := &osbuild.ContainerDeployOptions{
Exclude: []string{"/sysroot"},
Expand Down
14 changes: 11 additions & 3 deletions pkg/manifest/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ func (p *OS) serialize() osbuild.Pipeline {

if len(p.containerSpecs) > 0 {
images := osbuild.NewContainersInputForSources(p.containerSpecs)
localImages := osbuild.NewLocalContainersInputForSources(p.containerSpecs)

var storagePath string

Expand All @@ -417,9 +418,16 @@ func (p *OS) serialize() osbuild.Pipeline {
pipeline.AddStage(osbuild.NewContainersStorageConfStage(containerStoreOpts))
}

manifests := osbuild.NewFilesInputForManifestLists(p.containerSpecs)
skopeo := osbuild.NewSkopeoStageWithContainersStorage(storagePath, images, manifests)
pipeline.AddStage(skopeo)
if len(images.References) > 0 {
manifests := osbuild.NewFilesInputForManifestLists(p.containerSpecs)
skopeo := osbuild.NewSkopeoStageWithContainersStorage(storagePath, images, manifests)
pipeline.AddStage(skopeo)
}

if len(localImages.References) > 0 {
skopeo := osbuild.NewSkopeoStageWithContainersStorage(storagePath, localImages, nil)
pipeline.AddStage(skopeo)
}
}

pipeline.AddStage(osbuild.NewLocaleStage(&osbuild.LocaleStageOptions{Language: p.Language}))
Expand Down
9 changes: 8 additions & 1 deletion pkg/manifest/ostree_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,14 @@ func (p *OSTreeDeployment) doOSTreeContainerSpec(pipeline *osbuild.Pipeline, rep
Label: "root",
},
}
images := osbuild.NewContainersInputForSources([]container.Spec{cont})

var images osbuild.ContainersInput
if cont.LocalStorage {
images = osbuild.NewLocalContainersInputForSources([]container.Spec{cont})
} else {
images = osbuild.NewContainersInputForSources([]container.Spec{cont})
}

pipeline.AddStage(osbuild.NewOSTreeDeployContainerStage(options, images))
return ref
}
Expand Down

0 comments on commit 8204aab

Please sign in to comment.