From 806f88e133a05fad7b79f4771bf283ea0a2f6bd3 Mon Sep 17 00:00:00 2001 From: Ben Oukhanov Date: Thu, 8 Feb 2024 18:48:02 +0000 Subject: [PATCH] feat: arm containerdisks Add an option to build aarch64 containerdisks. Jira-Url: https://issues.redhat.com/browse/CNV-37406 Signed-off-by: Ben Oukhanov --- artifacts/centos/centos.go | 4 ++-- artifacts/centosstream/centos-stream.go | 4 ++-- artifacts/fedora/fedora.go | 8 ++++---- artifacts/ubuntu/ubuntu.go | 4 ++-- pkg/build/build.go | 5 ++--- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/artifacts/centos/centos.go b/artifacts/centos/centos.go index d13bcdb1..37118bf8 100644 --- a/artifacts/centos/centos.go +++ b/artifacts/centos/centos.go @@ -147,11 +147,11 @@ func (c *centos) Tests() []api.ArtifactTest { } // New accepts CentOS 7 and 8 versions. Example patterns are 7-2111, 7-2009, 8.3, 8.4, ... -func New(release string, additionalLabels map[string]string) *centos { +func New(release, arch string, additionalLabels map[string]string) *centos { return ¢os{ Version: release, Variant: "GenericCloud", - Arch: "x86_64", + Arch: arch, getter: &http.HTTPGetter{}, AdditionalLabels: additionalLabels, } diff --git a/artifacts/centosstream/centos-stream.go b/artifacts/centosstream/centos-stream.go index 3a5a7f3f..58e72061 100644 --- a/artifacts/centosstream/centos-stream.go +++ b/artifacts/centosstream/centos-stream.go @@ -116,10 +116,10 @@ func (c *centos) Tests() []api.ArtifactTest { } // New accepts CentOS Stream 8 and 9 versions. -func New(release string, exampleUserData *docs.UserData, additionalLabels map[string]string) *centos { +func New(release, arch string, exampleUserData *docs.UserData, additionalLabels map[string]string) *centos { return ¢os{ Version: release, - Arch: "x86_64", + Arch: arch, Variant: "GenericCloud", getter: &http.HTTPGetter{}, ExampleUserData: exampleUserData, diff --git a/artifacts/fedora/fedora.go b/artifacts/fedora/fedora.go index e57f6837..06be78b5 100644 --- a/artifacts/fedora/fedora.go +++ b/artifacts/fedora/fedora.go @@ -158,19 +158,19 @@ func (f *fedoraGatherer) releaseMatches(release *Release) bool { strings.HasSuffix(release.Link, "qcow2") } -func New(release string, additionalLabels map[string]string) *fedora { +func New(release, arch string, additionalLabels map[string]string) *fedora { return &fedora{ Version: release, - Arch: "x86_64", + Arch: arch, Variant: "Cloud", getter: &http.HTTPGetter{}, AdditionalLabels: additionalLabels, } } -func NewGatherer() *fedoraGatherer { +func NewGatherer(arch string) *fedoraGatherer { return &fedoraGatherer{ - Arch: "x86_64", + Arch: arch, Variant: "Cloud", getter: &http.HTTPGetter{}, } diff --git a/artifacts/ubuntu/ubuntu.go b/artifacts/ubuntu/ubuntu.go index 9ff4f4ba..d2acb2a4 100644 --- a/artifacts/ubuntu/ubuntu.go +++ b/artifacts/ubuntu/ubuntu.go @@ -79,10 +79,10 @@ func (u *ubuntu) Tests() []api.ArtifactTest { } } -func New(release string, additionalLabels map[string]string) *ubuntu { +func New(release, arch string, additionalLabels map[string]string) *ubuntu { return &ubuntu{ Version: release, - Arch: "x86_64", + Arch: arch, Variant: fmt.Sprintf("ubuntu-%v-server-cloudimg-amd64.img", release), getter: &http.HTTPGetter{}, AdditionalLabels: additionalLabels, diff --git a/pkg/build/build.go b/pkg/build/build.go index 161ed577..98f88d48 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -12,7 +12,6 @@ import ( const ( LabelShaSum = "shasum" - ImageArchitecture = "amd64" ) func ContainerDiskConfig(checksum string, additionalLabels map[string]string) v1.Config { @@ -34,7 +33,7 @@ func ContainerDiskConfig(checksum string, additionalLabels map[string]string) v1 return v1.Config{Labels: labels, Env: env} } -func ContainerDisk(imgPath string, config v1.Config) (v1.Image, error) { +func ContainerDisk(imgPath, imageArchitecture string, config v1.Config) (v1.Image, error) { img := empty.Image layer, err := tarball.LayerFromOpener(StreamLayerOpener(imgPath)) if err != nil { @@ -52,7 +51,7 @@ func ContainerDisk(imgPath string, config v1.Config) (v1.Image, error) { } // Modify the config file - cf.Architecture = ImageArchitecture + cf.Architecture = imageArchitecture cf.Config = config img, err = mutate.ConfigFile(img, cf)