From bcb927cf630dbea0536acb0d851a73bfa306fe97 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Thu, 20 Oct 2022 13:35:34 -0700 Subject: [PATCH] distroregistry: Add host's architecture name to the registry The store needs to know what default distribution and arch to use for images built with a blueprint that has no distro set. Store the host's architecture name along side the host's distribution details. SetHostArchName() allows this host arch to be overridden for testing, which uses arch names that do not match any host. --- internal/distroregistry/distroregistry.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/distroregistry/distroregistry.go b/internal/distroregistry/distroregistry.go index 7a168a3f9..a298e905a 100644 --- a/internal/distroregistry/distroregistry.go +++ b/internal/distroregistry/distroregistry.go @@ -40,14 +40,16 @@ type supportedDistro struct { } type Registry struct { - distros map[string]distro.Distro - hostDistro distro.Distro + distros map[string]distro.Distro + hostDistro distro.Distro + hostArchName string } func New(hostDistro distro.Distro, distros ...distro.Distro) (*Registry, error) { reg := &Registry{ - distros: make(map[string]distro.Distro), - hostDistro: hostDistro, + distros: make(map[string]distro.Distro), + hostDistro: hostDistro, + hostArchName: common.CurrentArch(), } for _, d := range distros { name := d.Name() @@ -136,3 +138,13 @@ func mangleHostDistroName(name string, isBeta, isStream bool) string { func (r *Registry) FromHost() distro.Distro { return r.hostDistro } + +// HostArchName returns the host's arch name +func (r *Registry) HostArchName() string { + return r.hostArchName +} + +// SetHostArchName can be used to override the host's arch name for testing +func (r *Registry) SetHostArchName(name string) { + r.hostArchName = name +}