From 8204aabd6582cbcf81ed1d2f05209a19509ee5d5 Mon Sep 17 00:00:00 2001 From: Gianluca Zuccarelli Date: Tue, 20 Feb 2024 12:56:16 +0000 Subject: [PATCH] manifest: add stage for local containers 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. --- pkg/manifest/anaconda_installer_iso_tree.go | 7 ++++++- pkg/manifest/build.go | 1 + pkg/manifest/os.go | 14 +++++++++++--- pkg/manifest/ostree_deployment.go | 9 ++++++++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/pkg/manifest/anaconda_installer_iso_tree.go b/pkg/manifest/anaconda_installer_iso_tree.go index 8aa063a258..5c305904e4 100644 --- a/pkg/manifest/anaconda_installer_iso_tree.go +++ b/pkg/manifest/anaconda_installer_iso_tree.go @@ -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{ diff --git a/pkg/manifest/build.go b/pkg/manifest/build.go index 2c38cc9e59..2a22b3ef40 100644 --- a/pkg/manifest/build.go +++ b/pkg/manifest/build.go @@ -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"}, diff --git a/pkg/manifest/os.go b/pkg/manifest/os.go index e6df046290..b792e15353 100644 --- a/pkg/manifest/os.go +++ b/pkg/manifest/os.go @@ -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 @@ -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})) diff --git a/pkg/manifest/ostree_deployment.go b/pkg/manifest/ostree_deployment.go index 3a79326f7e..06b27a0b11 100644 --- a/pkg/manifest/ostree_deployment.go +++ b/pkg/manifest/ostree_deployment.go @@ -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 }