distro: add ListArchs() to Distro interface
Similar to ListImageTypes() add a helper to enumerate the supported architectures. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
4a7519807e
commit
f903601ec4
8 changed files with 57 additions and 0 deletions
|
|
@ -24,6 +24,10 @@ type Distro interface {
|
|||
// for modularity support.
|
||||
ModulePlatformID() string
|
||||
|
||||
// Returns a sorted list of the names of the architectures this distro
|
||||
// supports.
|
||||
ListArchs() []string
|
||||
|
||||
// Returns an object representing the given architecture as support
|
||||
// by this distro.
|
||||
GetArch(arch string) (Arch, error)
|
||||
|
|
|
|||
|
|
@ -56,6 +56,15 @@ type fedora30ImageType struct {
|
|||
imageType *imageType
|
||||
}
|
||||
|
||||
func (d *Fedora30) ListArchs() []string {
|
||||
archs := make([]string, 0, len(d.arches))
|
||||
for name := range d.arches {
|
||||
archs = append(archs, name)
|
||||
}
|
||||
sort.Strings(archs)
|
||||
return archs
|
||||
}
|
||||
|
||||
func (d *Fedora30) GetArch(arch string) (distro.Arch, error) {
|
||||
a, exists := d.arches[arch]
|
||||
if !exists {
|
||||
|
|
|
|||
|
|
@ -56,6 +56,15 @@ type fedora31ImageType struct {
|
|||
imageType *imageType
|
||||
}
|
||||
|
||||
func (d *Fedora31) ListArchs() []string {
|
||||
archs := make([]string, 0, len(d.arches))
|
||||
for name := range d.arches {
|
||||
archs = append(archs, name)
|
||||
}
|
||||
sort.Strings(archs)
|
||||
return archs
|
||||
}
|
||||
|
||||
func (d *Fedora31) GetArch(arch string) (distro.Arch, error) {
|
||||
a, exists := d.arches[arch]
|
||||
if !exists {
|
||||
|
|
|
|||
|
|
@ -56,6 +56,15 @@ type fedora32ImageType struct {
|
|||
imageType *imageType
|
||||
}
|
||||
|
||||
func (d *Fedora32) ListArchs() []string {
|
||||
archs := make([]string, 0, len(d.arches))
|
||||
for name := range d.arches {
|
||||
archs = append(archs, name)
|
||||
}
|
||||
sort.Strings(archs)
|
||||
return archs
|
||||
}
|
||||
|
||||
func (d *Fedora32) GetArch(arch string) (distro.Arch, error) {
|
||||
a, exists := d.arches[arch]
|
||||
if !exists {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ type fedoraTestDistroImageType struct {
|
|||
arch *fedoraTestDistroArch
|
||||
}
|
||||
|
||||
func (d *FedoraTestDistro) ListArchs() []string {
|
||||
return []string{"x86_64"}
|
||||
}
|
||||
|
||||
func (d *FedoraTestDistro) GetArch(arch string) (distro.Arch, error) {
|
||||
if arch != "x86_64" {
|
||||
return nil, errors.New("invalid architecture: " + arch)
|
||||
|
|
|
|||
|
|
@ -57,6 +57,15 @@ type rhel81ImageType struct {
|
|||
imageType *imageType
|
||||
}
|
||||
|
||||
func (d *RHEL81) ListArchs() []string {
|
||||
archs := make([]string, 0, len(d.arches))
|
||||
for name := range d.arches {
|
||||
archs = append(archs, name)
|
||||
}
|
||||
sort.Strings(archs)
|
||||
return archs
|
||||
}
|
||||
|
||||
func (d *RHEL81) GetArch(arch string) (distro.Arch, error) {
|
||||
a, exists := d.arches[arch]
|
||||
if !exists {
|
||||
|
|
|
|||
|
|
@ -57,6 +57,15 @@ type rhel82ImageType struct {
|
|||
imageType *imageType
|
||||
}
|
||||
|
||||
func (d *RHEL82) ListArchs() []string {
|
||||
archs := make([]string, 0, len(d.arches))
|
||||
for name := range d.arches {
|
||||
archs = append(archs, name)
|
||||
}
|
||||
sort.Strings(archs)
|
||||
return archs
|
||||
}
|
||||
|
||||
func (d *RHEL82) GetArch(arch string) (distro.Arch, error) {
|
||||
a, exists := d.arches[arch]
|
||||
if !exists {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@ type testImageType struct{}
|
|||
const name = "test-distro"
|
||||
const modulePlatformID = "platform:test"
|
||||
|
||||
func (d *TestDistro) ListArchs() []string {
|
||||
return []string{"test_arch"}
|
||||
}
|
||||
|
||||
func (d *TestDistro) GetArch(arch string) (distro.Arch, error) {
|
||||
if arch != "test_arch" {
|
||||
return nil, errors.New("invalid arch: " + arch)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue