From 616258ee256250a4bac96bfb2cf0b9ec455c9592 Mon Sep 17 00:00:00 2001 From: Jordi Gil Date: Wed, 13 Apr 2022 15:22:32 -0400 Subject: [PATCH] distro: housekeeping with cpu arch and arch.Name() --- cmd/osbuild-image-tests/main_test.go | 3 ++- internal/boot/context-managers.go | 2 +- internal/distro/rhel8/distro.go | 12 ++++++------ internal/distro/rhel84/distro.go | 20 ++++++++++---------- internal/distro/rhel84/distro_test.go | 10 +++++----- internal/distro/rhel84/distro_v2.go | 2 +- internal/distro/rhel85/distro.go | 2 +- internal/distro/rhel85/distro_test.go | 2 +- internal/distro/rhel85/pipelines.go | 8 ++++---- internal/distro/rhel86/distro.go | 2 +- internal/distro/rhel86/distro_test.go | 2 +- internal/distro/rhel86/pipelines.go | 10 +++++----- internal/distro/rhel86/stage_options.go | 4 ++-- internal/distro/rhel90/distro.go | 2 +- internal/distro/rhel90/distro_test.go | 2 +- internal/distro/rhel90/pipelines.go | 8 ++++---- internal/distro/rhel90/stage_options.go | 4 ++-- internal/distro/rhel90beta/distro.go | 2 +- internal/distro/rhel90beta/distro_test.go | 2 +- internal/distro/rhel90beta/pipelines.go | 2 +- 20 files changed, 51 insertions(+), 50 deletions(-) diff --git a/cmd/osbuild-image-tests/main_test.go b/cmd/osbuild-image-tests/main_test.go index c02af51fe..e3936e2f7 100644 --- a/cmd/osbuild-image-tests/main_test.go +++ b/cmd/osbuild-image-tests/main_test.go @@ -30,6 +30,7 @@ import ( "github.com/osbuild/osbuild-composer/internal/boot/openstacktest" "github.com/osbuild/osbuild-composer/internal/boot/vmwaretest" "github.com/osbuild/osbuild-composer/internal/common" + "github.com/osbuild/osbuild-composer/internal/distro" "github.com/osbuild/osbuild-composer/internal/test" "github.com/osbuild/osbuild-composer/internal/upload/vmware" ) @@ -392,7 +393,7 @@ func testBootUsingOpenStack(t *testing.T, imagePath string) { currentArch := common.CurrentArch() // skip on aarch64 because we don't have aarch64 openstack or kvm machines - if currentArch == "aarch64" { + if currentArch == distro.Aarch64ArchName { t.Skip("Openstack boot test is skipped on aarch64.") // if no credentials are given, fall back to qemu } else if (creds == gophercloud.AuthOptions{}) { diff --git a/internal/boot/context-managers.go b/internal/boot/context-managers.go index de43bc35e..88b2a1206 100644 --- a/internal/boot/context-managers.go +++ b/internal/boot/context-managers.go @@ -139,7 +139,7 @@ func WithBootedQemuImage(image string, ns NetNS, f func() error) error { "-nographic", image, ) - } else if common.CurrentArch() == "aarch64" { + } else if common.CurrentArch() == distro.Aarch64ArchName { // This command does not use KVM as I was unable to make it work in Beaker, // once we have machines that can use KVM, enable it to make it faster qemuCmd = ns.NamespacedCommand( diff --git a/internal/distro/rhel8/distro.go b/internal/distro/rhel8/distro.go index dd020258b..3ef926576 100644 --- a/internal/distro/rhel8/distro.go +++ b/internal/distro/rhel8/distro.go @@ -166,7 +166,7 @@ func (t *imageType) MIMEType() string { func (t *imageType) OSTreeRef() string { if t.rpmOstree { - return fmt.Sprintf(ostreeRef, t.arch.name) + return fmt.Sprintf(ostreeRef, t.Arch().Name()) } return "" } @@ -342,7 +342,7 @@ func (t *imageType) pipeline(c *blueprint.Customizations, options distro.ImageOp p := &osbuild.Pipeline{} p.SetBuild(t.buildPipeline(repos, *t.arch, buildPackageSpecs), "org.osbuild.rhel82") - if t.arch.Name() == "s390x" { + if t.arch.Name() == distro.S390xArchName { p.AddStage(osbuild.NewKernelCmdlineStage(&osbuild.KernelCmdlineStageOptions{ RootFsUUID: "0bd700f8-090f-4556-b797-b340297ea1bd", KernelOpts: "net.ifnames=0 crashkernel=auto", @@ -354,7 +354,7 @@ func (t *imageType) pipeline(c *blueprint.Customizations, options distro.ImageOp if t.bootable { p.AddStage(osbuild.NewFSTabStage(t.fsTabStageOptions(t.arch.uefi))) - if t.arch.Name() != "s390x" { + if t.arch.Name() != distro.S390xArchName { p.AddStage(osbuild.NewGRUB2Stage(t.grub2StageOptions(t.kernelOptions, c.GetKernel(), t.arch.uefi))) } } @@ -404,7 +404,7 @@ func (t *imageType) pipeline(c *blueprint.Customizations, options distro.ImageOp p.AddStage(osbuild.NewFirewallStage(t.firewallStageOptions(firewall))) } - if t.arch.Name() == "s390x" { + if t.arch.Name() == distro.S390xArchName { p.AddStage(osbuild.NewZiplStage(&osbuild.ZiplStageOptions{})) } @@ -584,7 +584,7 @@ func qemuAssembler(format string, filename string, uefi bool, arch distro.Arch, }, } } else { - if arch.Name() == "ppc64le" { + if arch.Name() == distro.Ppc64leArchName { options = osbuild.QEMUAssemblerOptions{ Bootloader: &osbuild.QEMUBootloader{ Type: "grub2", @@ -612,7 +612,7 @@ func qemuAssembler(format string, filename string, uefi bool, arch distro.Arch, }, }, } - } else if arch.Name() == "s390x" { + } else if arch.Name() == distro.S390xArchName { options = osbuild.QEMUAssemblerOptions{ Bootloader: &osbuild.QEMUBootloader{ Type: "zipl", diff --git a/internal/distro/rhel84/distro.go b/internal/distro/rhel84/distro.go index caeee47fb..7bf2503fd 100644 --- a/internal/distro/rhel84/distro.go +++ b/internal/distro/rhel84/distro.go @@ -200,7 +200,7 @@ func (t *imageType) MIMEType() string { func (t *imageType) OSTreeRef() string { if t.rpmOstree { - return fmt.Sprintf(ostreeRef, t.arch.name) + return fmt.Sprintf(ostreeRef, t.Arch().Name()) } return "" } @@ -407,7 +407,7 @@ func (t *imageType) pipeline(c *blueprint.Customizations, options distro.ImageOp p.SetBuild(t.buildPipeline(repos, *t.arch, buildPackageSpecs), "org.osbuild.rhel84") } - if t.arch.Name() == "s390x" { + if t.arch.Name() == distro.S390xArchName { if pt == nil { panic("s390x image must have a partition table, this is a programming error") } @@ -431,7 +431,7 @@ func (t *imageType) pipeline(c *blueprint.Customizations, options distro.ImageOp } if t.bootable { - if t.arch.Name() != "s390x" { + if t.arch.Name() != distro.S390xArchName { p.AddStage(osbuild.NewGRUB2Stage(t.grub2StageOptions(pt, t.kernelOptions, c.GetKernel(), packageSpecs, t.arch.uefi, t.arch.legacy))) } } @@ -483,7 +483,7 @@ func (t *imageType) pipeline(c *blueprint.Customizations, options distro.ImageOp p.AddStage(osbuild.NewFirewallStage(t.firewallStageOptions(firewall))) } - if t.arch.Name() == "s390x" { + if t.arch.Name() == distro.S390xArchName { p.AddStage(osbuild.NewZiplStage(&osbuild.ZiplStageOptions{})) } @@ -653,7 +653,7 @@ func (t *imageType) selinuxStageOptions() *osbuild.SELinuxStageOptions { } func defaultPartitionTable(imageSize uint64, arch distro.Arch, rng *rand.Rand) disk.PartitionTable { - if arch.Name() == "x86_64" { + if arch.Name() == distro.X86_64ArchName { return disk.PartitionTable{ Size: imageSize, UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", @@ -696,7 +696,7 @@ func defaultPartitionTable(imageSize uint64, arch distro.Arch, rng *rand.Rand) d }, }, } - } else if arch.Name() == "aarch64" { + } else if arch.Name() == distro.Aarch64ArchName { return disk.PartitionTable{ Size: imageSize, UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", @@ -732,7 +732,7 @@ func defaultPartitionTable(imageSize uint64, arch distro.Arch, rng *rand.Rand) d }, }, } - } else if arch.Name() == "ppc64le" { + } else if arch.Name() == distro.Ppc64leArchName { return disk.PartitionTable{ Size: imageSize, UUID: "0x14fc63d2", @@ -756,7 +756,7 @@ func defaultPartitionTable(imageSize uint64, arch distro.Arch, rng *rand.Rand) d }, }, } - } else if arch.Name() == "s390x" { + } else if arch.Name() == distro.S390xArchName { return disk.PartitionTable{ Size: imageSize, UUID: "0x14fc63d2", @@ -793,12 +793,12 @@ func qemuAssembler(pt *disk.PartitionTable, format string, filename string, imag options.Bootloader = &osbuild.QEMUBootloader{ Type: "grub2", } - } else if arch.Name() == "ppc64le" { + } else if arch.Name() == distro.Ppc64leArchName { options.Bootloader = &osbuild.QEMUBootloader{ Type: "grub2", Platform: "powerpc-ieee1275", } - } else if arch.Name() == "s390x" { + } else if arch.Name() == distro.S390xArchName { options.Bootloader = &osbuild.QEMUBootloader{ Type: "zipl", } diff --git a/internal/distro/rhel84/distro_test.go b/internal/distro/rhel84/distro_test.go index 474d002c5..afe9da809 100644 --- a/internal/distro/rhel84/distro_test.go +++ b/internal/distro/rhel84/distro_test.go @@ -220,7 +220,7 @@ func TestImageType_Name(t *testing.T) { for _, dist := range rhelFamilyDistros { t.Run(dist.name, func(t *testing.T) { for _, mapping := range imgMap { - if mapping.arch == "s390x" && dist.name == "centos" { + if mapping.arch == distro.S390xArchName && dist.name == "centos" { continue } arch, err := dist.distro.GetArch(mapping.arch) @@ -443,7 +443,7 @@ func TestDistro_ManifestError(t *testing.T) { for _, archName := range r8distro.ListArches() { arch, _ := r8distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { - if archName == "s390x" && imgTypeName == "tar" { + if archName == distro.S390xArchName && imgTypeName == "tar" { // broken arch-imgType combination; see // https://github.com/osbuild/osbuild-composer/issues/1220 continue @@ -514,7 +514,7 @@ func TestArchitecture_ListImageTypes(t *testing.T) { for _, dist := range rhelFamilyDistros { t.Run(dist.name, func(t *testing.T) { for _, mapping := range imgMap { - if mapping.arch == "s390x" && dist.name == "centos" { + if mapping.arch == distro.S390xArchName && dist.name == "centos" { continue } arch, err := dist.distro.GetArch(mapping.arch) @@ -623,7 +623,7 @@ func TestDistro_CustomFileSystemManifestError(t *testing.T) { for _, archName := range d.ListArches() { arch, _ := d.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { - if (archName == "s390x" && imgTypeName == "tar") || imgTypeName == "rhel-edge-installer" { + if (archName == distro.S390xArchName && imgTypeName == "tar") || imgTypeName == "rhel-edge-installer" { continue } imgType, _ := arch.GetImageType(imgTypeName) @@ -660,7 +660,7 @@ func TestDistro_TestRootMountPoint(t *testing.T) { for _, archName := range d.ListArches() { arch, _ := d.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { - if (archName == "s390x" && imgTypeName == "tar") || imgTypeName == "rhel-edge-installer" { + if (archName == distro.S390xArchName && imgTypeName == "tar") || imgTypeName == "rhel-edge-installer" { continue } imgType, _ := arch.GetImageType(imgTypeName) diff --git a/internal/distro/rhel84/distro_v2.go b/internal/distro/rhel84/distro_v2.go index 69171d39b..d6d7f86f7 100644 --- a/internal/distro/rhel84/distro_v2.go +++ b/internal/distro/rhel84/distro_v2.go @@ -60,7 +60,7 @@ func (t *imageTypeS2) MIMEType() string { func (t *imageTypeS2) OSTreeRef() string { if t.rpmOstree { - return fmt.Sprintf(ostreeRef, t.arch.name) + return fmt.Sprintf(ostreeRef, t.Arch().Name()) } return "" } diff --git a/internal/distro/rhel85/distro.go b/internal/distro/rhel85/distro.go index 4d901face..562972eb5 100644 --- a/internal/distro/rhel85/distro.go +++ b/internal/distro/rhel85/distro.go @@ -214,7 +214,7 @@ func (t *imageType) MIMEType() string { func (t *imageType) OSTreeRef() string { if t.rpmOstree { - return fmt.Sprintf(ostreeRef, t.arch.name) + return fmt.Sprintf(ostreeRef, t.Arch().Name()) } return "" } diff --git a/internal/distro/rhel85/distro_test.go b/internal/distro/rhel85/distro_test.go index c142cfc74..b67b5a812 100644 --- a/internal/distro/rhel85/distro_test.go +++ b/internal/distro/rhel85/distro_test.go @@ -317,7 +317,7 @@ func TestImageType_Name(t *testing.T) { for _, dist := range rhelFamilyDistros { t.Run(dist.name, func(t *testing.T) { for _, mapping := range imgMap { - if mapping.arch == "s390x" && dist.name == "centos" { + if mapping.arch == distro.S390xArchName && dist.name == "centos" { continue } arch, err := dist.distro.GetArch(mapping.arch) diff --git a/internal/distro/rhel85/pipelines.go b/internal/distro/rhel85/pipelines.go index 5e67e2856..ce8005f9c 100644 --- a/internal/distro/rhel85/pipelines.go +++ b/internal/distro/rhel85/pipelines.go @@ -62,7 +62,7 @@ func qcow2Pipelines(t *imageType, customizations *blueprint.Customizations, opti } func prependKernelCmdlineStage(pipeline *osbuild.Pipeline, t *imageType, pt *disk.PartitionTable) *osbuild.Pipeline { - if t.arch.name == distro.S390xArchName { + if t.Arch().Name() == distro.S390xArchName { rootFs := pt.FindMountable("/") if rootFs == nil { panic("s390x image must have a root filesystem, this is a programming error") @@ -1461,9 +1461,9 @@ func simplifiedInstallerEFIBootTreePipeline(installDevice, kernelVer, arch strin var architectures []string - if arch == "x86_64" { + if arch == distro.X86_64ArchName { architectures = []string{"IA32", "X64"} - } else if arch == "aarch64" { + } else if arch == distro.Aarch64ArchName { architectures = []string{"AA64"} } else { panic("unsupported architecture") @@ -1705,7 +1705,7 @@ func qemuPipeline(inputPipelineName, inputFilename, outputFilename string, forma } func bootloaderConfigStage(t *imageType, partitionTable *disk.PartitionTable, kernel *blueprint.KernelCustomization, kernelVer string, install, greenboot bool) *osbuild.Stage { - if t.arch.name == distro.S390xArchName { + if t.Arch().Name() == distro.S390xArchName { return osbuild.NewZiplStage(new(osbuild.ZiplStageOptions)) } diff --git a/internal/distro/rhel86/distro.go b/internal/distro/rhel86/distro.go index f405186aa..7703fd1c1 100644 --- a/internal/distro/rhel86/distro.go +++ b/internal/distro/rhel86/distro.go @@ -278,7 +278,7 @@ func (t *imageType) MIMEType() string { func (t *imageType) OSTreeRef() string { d := t.arch.distro if t.rpmOstree { - return fmt.Sprintf(d.ostreeRefTmpl, t.arch.name) + return fmt.Sprintf(d.ostreeRefTmpl, t.Arch().Name()) } return "" } diff --git a/internal/distro/rhel86/distro_test.go b/internal/distro/rhel86/distro_test.go index b09876e32..47697d955 100644 --- a/internal/distro/rhel86/distro_test.go +++ b/internal/distro/rhel86/distro_test.go @@ -335,7 +335,7 @@ func TestImageType_Name(t *testing.T) { for _, dist := range rhelFamilyDistros { t.Run(dist.name, func(t *testing.T) { for _, mapping := range imgMap { - if mapping.arch == "s390x" && dist.name == "centos" { + if mapping.arch == distro.S390xArchName && dist.name == "centos" { continue } arch, err := dist.distro.GetArch(mapping.arch) diff --git a/internal/distro/rhel86/pipelines.go b/internal/distro/rhel86/pipelines.go index e74fc4e49..5bc6d2ac3 100644 --- a/internal/distro/rhel86/pipelines.go +++ b/internal/distro/rhel86/pipelines.go @@ -41,7 +41,7 @@ func qcow2Pipelines(t *imageType, customizations *blueprint.Customizations, opti } func prependKernelCmdlineStage(pipeline *osbuild.Pipeline, t *imageType, pt *disk.PartitionTable) *osbuild.Pipeline { - if t.arch.name == distro.S390xArchName { + if t.Arch().Name() == distro.S390xArchName { rootFs := pt.FindMountable("/") if rootFs == nil { panic("s390x image must have a root filesystem, this is a programming error") @@ -238,7 +238,7 @@ func edgeInstallerPipelines(t *imageType, customizations *blueprint.Customizatio pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner)) installerPackages := packageSetSpecs[installerPkgsKey] d := t.arch.distro - archName := t.arch.name + archName := t.Arch().Name() kernelVer := rpmmd.GetVerStrFromPackageSpecListPanic(installerPackages, "kernel") ostreeRepoPath := "/ostree/repo" payloadStages := ostreePayloadStages(options, ostreeRepoPath) @@ -285,7 +285,7 @@ func imageInstallerPipelines(t *imageType, customizations *blueprint.Customizati if err != nil { return nil, err } - archName := t.arch.name + archName := t.Arch().Name() d := t.arch.distro pipelines = append(pipelines, *anacondaTreePipeline(repos, installerPackages, kernelVer, archName, d.product, d.osVersion, "BaseOS", true)) isolabel := fmt.Sprintf(d.isolabelTmpl, archName) @@ -741,7 +741,7 @@ func edgeSimplifiedInstallerPipelines(t *imageType, customizations *blueprint.Cu // create boot ISO with raw image d := t.arch.distro - archName := t.arch.name + archName := t.Arch().Name() installerTreePipeline := simplifiedInstallerTreePipeline(repos, installerPackages, kernelVer, archName, d.product, d.osVersion, "edge", customizations.GetFDO()) isolabel := fmt.Sprintf(d.isolabelTmpl, archName) efibootTreePipeline := simplifiedInstallerEFIBootTreePipeline(installDevice, kernelVer, archName, d.vendor, d.product, d.osVersion, isolabel, customizations.GetFDO()) @@ -1100,7 +1100,7 @@ func qemuPipeline(inputPipelineName, inputFilename, outputFilename string, forma } func bootloaderConfigStage(t *imageType, partitionTable disk.PartitionTable, kernel *blueprint.KernelCustomization, kernelVer string, install, greenboot bool) *osbuild.Stage { - if t.arch.name == distro.S390xArchName { + if t.Arch().Name() == distro.S390xArchName { return osbuild.NewZiplStage(new(osbuild.ZiplStageOptions)) } diff --git a/internal/distro/rhel86/stage_options.go b/internal/distro/rhel86/stage_options.go index 911dbcab7..ae18c51de 100644 --- a/internal/distro/rhel86/stage_options.go +++ b/internal/distro/rhel86/stage_options.go @@ -209,9 +209,9 @@ func bootISOMonoStageOptions(kernelVer, arch, vendor, product, osVersion, isolab func grubISOStageOptions(installDevice, kernelVer, arch, vendor, product, osVersion, isolabel string, fdo *blueprint.FDOCustomization) *osbuild.GrubISOStageOptions { var architectures []string - if arch == "x86_64" { + if arch == distro.X86_64ArchName { architectures = []string{"IA32", "X64"} - } else if arch == "aarch64" { + } else if arch == distro.Aarch64ArchName { architectures = []string{"AA64"} } else { panic("unsupported architecture") diff --git a/internal/distro/rhel90/distro.go b/internal/distro/rhel90/distro.go index c998d1994..c98b6c3ea 100644 --- a/internal/distro/rhel90/distro.go +++ b/internal/distro/rhel90/distro.go @@ -278,7 +278,7 @@ func (t *imageType) MIMEType() string { func (t *imageType) OSTreeRef() string { d := t.arch.distro if t.rpmOstree { - return fmt.Sprintf(d.ostreeRefTmpl, t.arch.name) + return fmt.Sprintf(d.ostreeRefTmpl, t.Arch().Name()) } return "" } diff --git a/internal/distro/rhel90/distro_test.go b/internal/distro/rhel90/distro_test.go index 141d915f4..e27c71a05 100644 --- a/internal/distro/rhel90/distro_test.go +++ b/internal/distro/rhel90/distro_test.go @@ -318,7 +318,7 @@ func TestImageType_Name(t *testing.T) { for _, dist := range rhelFamilyDistros { t.Run(dist.name, func(t *testing.T) { for _, mapping := range imgMap { - if mapping.arch == "s390x" && dist.name == "centos" { + if mapping.arch == distro.S390xArchName && dist.name == "centos" { continue } arch, err := dist.distro.GetArch(mapping.arch) diff --git a/internal/distro/rhel90/pipelines.go b/internal/distro/rhel90/pipelines.go index fb90c86d8..faa9dfcdb 100644 --- a/internal/distro/rhel90/pipelines.go +++ b/internal/distro/rhel90/pipelines.go @@ -230,7 +230,7 @@ func edgeInstallerPipelines(t *imageType, customizations *blueprint.Customizatio pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner)) installerPackages := packageSetSpecs[installerPkgsKey] d := t.arch.distro - archName := t.arch.name + archName := t.Arch().Name() kernelVer := rpmmd.GetVerStrFromPackageSpecListPanic(installerPackages, "kernel") ostreeRepoPath := "/ostree/repo" payloadStages := ostreePayloadStages(options, ostreeRepoPath) @@ -277,7 +277,7 @@ func imageInstallerPipelines(t *imageType, customizations *blueprint.Customizati if err != nil { return nil, err } - archName := t.arch.name + archName := t.Arch().Name() d := t.arch.distro pipelines = append(pipelines, *anacondaTreePipeline(repos, installerPackages, kernelVer, archName, d.product, d.osVersion, "BaseOS", true)) isolabel := fmt.Sprintf(d.isolabelTmpl, archName) @@ -738,7 +738,7 @@ func edgeSimplifiedInstallerPipelines(t *imageType, customizations *blueprint.Cu // create boot ISO with raw image d := t.arch.distro - archName := t.arch.name + archName := t.Arch().Name() installerTreePipeline := simplifiedInstallerTreePipeline(repos, installerPackages, kernelVer, archName, d.product, d.osVersion, "edge", customizations.GetFDO()) isolabel := fmt.Sprintf(d.isolabelTmpl, archName) efibootTreePipeline := simplifiedInstallerEFIBootTreePipeline(installDevice, kernelVer, archName, d.vendor, d.product, d.osVersion, isolabel, customizations.GetFDO()) @@ -1092,7 +1092,7 @@ func qemuPipeline(inputPipelineName, inputFilename, outputFilename string, forma } func bootloaderConfigStage(t *imageType, partitionTable disk.PartitionTable, kernelVer string, install, greenboot bool) *osbuild.Stage { - if t.arch.name == distro.S390xArchName { + if t.Arch().Name() == distro.S390xArchName { return osbuild.NewZiplStage(new(osbuild.ZiplStageOptions)) } diff --git a/internal/distro/rhel90/stage_options.go b/internal/distro/rhel90/stage_options.go index cb33cc793..b9604d105 100644 --- a/internal/distro/rhel90/stage_options.go +++ b/internal/distro/rhel90/stage_options.go @@ -209,9 +209,9 @@ func bootISOMonoStageOptions(kernelVer, arch, vendor, product, osVersion, isolab func grubISOStageOptions(installDevice, kernelVer, arch, vendor, product, osVersion, isolabel string, fdo *blueprint.FDOCustomization) *osbuild.GrubISOStageOptions { var architectures []string - if arch == "x86_64" { + if arch == distro.X86_64ArchName { architectures = []string{"X64"} - } else if arch == "aarch64" { + } else if arch == distro.Aarch64ArchName { architectures = []string{"AA64"} } else { panic("unsupported architecture") diff --git a/internal/distro/rhel90beta/distro.go b/internal/distro/rhel90beta/distro.go index abb0dadbb..3e7a28538 100644 --- a/internal/distro/rhel90beta/distro.go +++ b/internal/distro/rhel90beta/distro.go @@ -223,7 +223,7 @@ func (t *imageType) MIMEType() string { func (t *imageType) OSTreeRef() string { if t.rpmOstree { - return fmt.Sprintf(ostreeRef, t.arch.name) + return fmt.Sprintf(ostreeRef, t.Arch().Name()) } return "" } diff --git a/internal/distro/rhel90beta/distro_test.go b/internal/distro/rhel90beta/distro_test.go index ee70eb4dd..f4bc7767c 100644 --- a/internal/distro/rhel90beta/distro_test.go +++ b/internal/distro/rhel90beta/distro_test.go @@ -308,7 +308,7 @@ func TestImageType_Name(t *testing.T) { for _, dist := range rhelFamilyDistros { t.Run(dist.name, func(t *testing.T) { for _, mapping := range imgMap { - if mapping.arch == "s390x" && dist.name == "centos" { + if mapping.arch == distro.S390xArchName && dist.name == "centos" { continue } arch, err := dist.distro.GetArch(mapping.arch) diff --git a/internal/distro/rhel90beta/pipelines.go b/internal/distro/rhel90beta/pipelines.go index d73351b09..5eea71473 100644 --- a/internal/distro/rhel90beta/pipelines.go +++ b/internal/distro/rhel90beta/pipelines.go @@ -1097,7 +1097,7 @@ func qemuPipeline(inputPipelineName, inputFilename, outputFilename string, forma } func bootloaderConfigStage(t *imageType, partitionTable *disk.PartitionTable, kernel *blueprint.KernelCustomization, kernelVer string) *osbuild.Stage { - if t.arch.name == distro.S390xArchName { + if t.Arch().Name() == distro.S390xArchName { return osbuild.NewZiplStage(new(osbuild.ZiplStageOptions)) }