From 9c72009bff77dbd70b678ec7d3cd77d8e2510a9d Mon Sep 17 00:00:00 2001 From: Gianluca Zuccarelli Date: Tue, 12 Dec 2023 12:42:16 +0000 Subject: [PATCH] distro/multi: additional container storage Enable a custom storage path for containers to be pulled into. Jira: https://issues.redhat.com/browse/HMS-3235 --- pkg/distro/fedora/images.go | 4 ++++ pkg/distro/fedora/imagetype.go | 8 ++++++++ pkg/distro/rhel8/images.go | 4 ++++ pkg/distro/rhel8/imagetype.go | 8 ++++++++ pkg/distro/rhel9/images.go | 4 ++++ pkg/distro/rhel9/imagetype.go | 8 ++++++++ 6 files changed, 36 insertions(+) diff --git a/pkg/distro/fedora/images.go b/pkg/distro/fedora/images.go index 162bdebb38..d6e20023a1 100644 --- a/pkg/distro/fedora/images.go +++ b/pkg/distro/fedora/images.go @@ -147,6 +147,10 @@ func osCustomizations( osc.ContainersStorage = &storagePath } + if containerStorage := c.GetContainerStorage(); containerStorage != nil { + osc.ContainersStorage = containerStorage.StoragePath + } + customRepos, err := c.GetRepositories() if err != nil { // This shouldn't happen and since the repos diff --git a/pkg/distro/fedora/imagetype.go b/pkg/distro/fedora/imagetype.go index 02939cf924..478004f046 100644 --- a/pkg/distro/fedora/imagetype.go +++ b/pkg/distro/fedora/imagetype.go @@ -256,6 +256,14 @@ func (t *imageType) checkOptions(bp *blueprint.Blueprint, options distro.ImageOp return nil, fmt.Errorf("embedding containers is not supported for %s on %s", t.name, t.arch.distro.name) } + if len(bp.Containers) > 0 { + for _, container := range bp.Containers { + if err := container.Validate(); err != nil { + return nil, err + } + } + } + if options.OSTree != nil { if err := options.OSTree.Validate(); err != nil { return nil, err diff --git a/pkg/distro/rhel8/images.go b/pkg/distro/rhel8/images.go index 8f561686c4..ffc0f4caf6 100644 --- a/pkg/distro/rhel8/images.go +++ b/pkg/distro/rhel8/images.go @@ -164,6 +164,10 @@ func osCustomizations( osc.ContainersStorage = &storagePath } + if containerStorage := c.GetContainerStorage(); containerStorage != nil { + osc.ContainersStorage = containerStorage.StoragePath + } + // set yum repos first, so it doesn't get overridden by // imageConfig.YUMRepos osc.YUMRepos = imageConfig.YUMRepos diff --git a/pkg/distro/rhel8/imagetype.go b/pkg/distro/rhel8/imagetype.go index 509be936f5..5343b9dff9 100644 --- a/pkg/distro/rhel8/imagetype.go +++ b/pkg/distro/rhel8/imagetype.go @@ -290,6 +290,14 @@ func (t *imageType) checkOptions(bp *blueprint.Blueprint, options distro.ImageOp return warnings, fmt.Errorf("embedding containers is not supported for %s on %s", t.name, t.arch.distro.name) } + if len(bp.Containers) > 0 { + for _, container := range bp.Containers { + if err := container.Validate(); err != nil { + return nil, err + } + } + } + if options.OSTree != nil { if err := options.OSTree.Validate(); err != nil { return nil, err diff --git a/pkg/distro/rhel9/images.go b/pkg/distro/rhel9/images.go index 588b9bf520..88e86f82d9 100644 --- a/pkg/distro/rhel9/images.go +++ b/pkg/distro/rhel9/images.go @@ -161,6 +161,10 @@ func osCustomizations( osc.ContainersStorage = &storagePath } + if containerStorage := c.GetContainerStorage(); containerStorage != nil { + osc.ContainersStorage = containerStorage.StoragePath + } + // set yum repos first, so it doesn't get overridden by // imageConfig.YUMRepos osc.YUMRepos = imageConfig.YUMRepos diff --git a/pkg/distro/rhel9/imagetype.go b/pkg/distro/rhel9/imagetype.go index 5d98f73b05..d4713ce17f 100644 --- a/pkg/distro/rhel9/imagetype.go +++ b/pkg/distro/rhel9/imagetype.go @@ -290,6 +290,14 @@ func (t *imageType) checkOptions(bp *blueprint.Blueprint, options distro.ImageOp return warnings, fmt.Errorf("embedding containers is not supported for %s on %s", t.name, t.arch.distro.name) } + if len(bp.Containers) > 0 { + for _, container := range bp.Containers { + if err := container.Validate(); err != nil { + return nil, err + } + } + } + if options.OSTree != nil { if err := options.OSTree.Validate(); err != nil { return nil, err