distro/rhel84: disable s390x and rhel-commit-edge for Centos
s390x isn't supported on Centos. rhel-commit-edge sounds just wrong for Centos. We can revert this change any time. The thing is that I wasn't able to find something like CentOS IoT and we don't want to be in a position of defining a new distribution spin. Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
parent
4492448f49
commit
bf4280d1e2
2 changed files with 62 additions and 26 deletions
|
|
@ -84,8 +84,11 @@ func (d *distribution) GetArch(arch string) (distro.Arch, error) {
|
|||
return &a, nil
|
||||
}
|
||||
|
||||
func (d *distribution) setArches(arches ...architecture) {
|
||||
d.arches = map[string]architecture{}
|
||||
func (d *distribution) addArches(arches ...architecture) {
|
||||
if d.arches == nil {
|
||||
d.arches = map[string]architecture{}
|
||||
}
|
||||
|
||||
for _, a := range arches {
|
||||
d.arches[a.name] = architecture{
|
||||
distro: d,
|
||||
|
|
@ -120,8 +123,11 @@ func (a *architecture) GetImageType(imageType string) (distro.ImageType, error)
|
|||
return &t, nil
|
||||
}
|
||||
|
||||
func (a *architecture) setImageTypes(imageTypes ...imageType) {
|
||||
a.imageTypes = map[string]imageType{}
|
||||
func (a *architecture) addImageTypes(imageTypes ...imageType) {
|
||||
if a.imageTypes == nil {
|
||||
a.imageTypes = map[string]imageType{}
|
||||
}
|
||||
|
||||
for _, it := range imageTypes {
|
||||
a.imageTypes[it.name] = imageType{
|
||||
arch: a,
|
||||
|
|
@ -1195,9 +1201,8 @@ func newDistro(isCentos bool) distro.Distro {
|
|||
legacy: "i386-pc",
|
||||
uefi: true,
|
||||
}
|
||||
x8664.setImageTypes(
|
||||
x8664.addImageTypes(
|
||||
amiImgType,
|
||||
edgeImgTypeX86_64,
|
||||
qcow2ImageType,
|
||||
openstackImgType,
|
||||
tarImgType,
|
||||
|
|
@ -1205,6 +1210,10 @@ func newDistro(isCentos bool) distro.Distro {
|
|||
vmdkImgType,
|
||||
)
|
||||
|
||||
if !isCentos {
|
||||
x8664.addImageTypes(edgeImgTypeX86_64)
|
||||
}
|
||||
|
||||
aarch64 := architecture{
|
||||
distro: &r,
|
||||
name: "aarch64",
|
||||
|
|
@ -1217,14 +1226,17 @@ func newDistro(isCentos bool) distro.Distro {
|
|||
},
|
||||
uefi: true,
|
||||
}
|
||||
aarch64.setImageTypes(
|
||||
aarch64.addImageTypes(
|
||||
amiImgType,
|
||||
edgeImgTypeAarch64,
|
||||
qcow2ImageType,
|
||||
openstackImgType,
|
||||
tarImgType,
|
||||
)
|
||||
|
||||
if !isCentos {
|
||||
aarch64.addImageTypes(edgeImgTypeAarch64)
|
||||
}
|
||||
|
||||
ppc64le := architecture{
|
||||
distro: &r,
|
||||
name: "ppc64le",
|
||||
|
|
@ -1241,7 +1253,7 @@ func newDistro(isCentos bool) distro.Distro {
|
|||
legacy: "powerpc-ieee1275",
|
||||
uefi: false,
|
||||
}
|
||||
ppc64le.setImageTypes(
|
||||
ppc64le.addImageTypes(
|
||||
qcow2ImageType,
|
||||
tarImgType,
|
||||
)
|
||||
|
|
@ -1255,12 +1267,16 @@ func newDistro(isCentos bool) distro.Distro {
|
|||
},
|
||||
uefi: false,
|
||||
}
|
||||
s390x.setImageTypes(
|
||||
s390x.addImageTypes(
|
||||
tarImgType,
|
||||
qcow2ImageType,
|
||||
)
|
||||
|
||||
r.setArches(x8664, aarch64, ppc64le, s390x)
|
||||
r.addArches(x8664, aarch64, ppc64le)
|
||||
|
||||
if !isCentos {
|
||||
r.addArches(s390x)
|
||||
}
|
||||
|
||||
return &r
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,9 +206,15 @@ 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" {
|
||||
continue
|
||||
}
|
||||
arch, err := dist.distro.GetArch(mapping.arch)
|
||||
if assert.NoError(t, err) {
|
||||
for _, imgName := range mapping.imgNames {
|
||||
if imgName == "rhel-edge-commit" && dist.name == "centos" {
|
||||
continue
|
||||
}
|
||||
imgType, err := arch.GetImageType(imgName)
|
||||
if assert.NoError(t, err) {
|
||||
assert.Equalf(t, imgName, imgType.Name(), "arch: %s", mapping.arch)
|
||||
|
|
@ -444,8 +450,9 @@ func TestDistro_ManifestError(t *testing.T) {
|
|||
|
||||
func TestArchitecture_ListImageTypes(t *testing.T) {
|
||||
imgMap := []struct {
|
||||
arch string
|
||||
imgNames []string
|
||||
arch string
|
||||
imgNames []string
|
||||
rhelAdditionalImageTypes []string
|
||||
}{
|
||||
{
|
||||
arch: "x86_64",
|
||||
|
|
@ -453,11 +460,11 @@ func TestArchitecture_ListImageTypes(t *testing.T) {
|
|||
"ami",
|
||||
"qcow2",
|
||||
"openstack",
|
||||
"rhel-edge-commit",
|
||||
"tar",
|
||||
"vhd",
|
||||
"vmdk",
|
||||
},
|
||||
rhelAdditionalImageTypes: []string{"rhel-edge-commit"},
|
||||
},
|
||||
{
|
||||
arch: "aarch64",
|
||||
|
|
@ -465,9 +472,9 @@ func TestArchitecture_ListImageTypes(t *testing.T) {
|
|||
"ami",
|
||||
"qcow2",
|
||||
"openstack",
|
||||
"rhel-edge-commit",
|
||||
"tar",
|
||||
},
|
||||
rhelAdditionalImageTypes: []string{"rhel-edge-commit"},
|
||||
},
|
||||
{
|
||||
arch: "ppc64le",
|
||||
|
|
@ -488,28 +495,40 @@ 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" {
|
||||
continue
|
||||
}
|
||||
arch, err := dist.distro.GetArch(mapping.arch)
|
||||
require.NoError(t, err)
|
||||
imageTypes := arch.ListImageTypes()
|
||||
require.ElementsMatch(t, mapping.imgNames, imageTypes)
|
||||
|
||||
var expectedImageTypes []string
|
||||
expectedImageTypes = append(expectedImageTypes, mapping.imgNames...)
|
||||
if dist.name == "rhel" {
|
||||
expectedImageTypes = append(expectedImageTypes, mapping.rhelAdditionalImageTypes...)
|
||||
}
|
||||
|
||||
require.ElementsMatch(t, expectedImageTypes, imageTypes)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRhel84_ListArches(t *testing.T) {
|
||||
for _, dist := range rhelFamilyDistros {
|
||||
t.Run(dist.name, func(t *testing.T) {
|
||||
arches := dist.distro.ListArches()
|
||||
assert.Equal(t, []string{"aarch64", "ppc64le", "s390x", "x86_64"}, arches)
|
||||
})
|
||||
}
|
||||
arches := rhel84.New().ListArches()
|
||||
assert.Equal(t, []string{"aarch64", "ppc64le", "s390x", "x86_64"}, arches)
|
||||
}
|
||||
|
||||
func TestCentos_ListArches(t *testing.T) {
|
||||
arches := rhel84.NewCentos().ListArches()
|
||||
assert.Equal(t, []string{"aarch64", "ppc64le", "x86_64"}, arches)
|
||||
}
|
||||
|
||||
func TestRhel84_GetArch(t *testing.T) {
|
||||
arches := []struct {
|
||||
name string
|
||||
errorExpected bool
|
||||
name string
|
||||
errorExpected bool
|
||||
errorExpectedInCentos bool
|
||||
}{
|
||||
{
|
||||
name: "x86_64",
|
||||
|
|
@ -521,7 +540,8 @@ func TestRhel84_GetArch(t *testing.T) {
|
|||
name: "ppc64le",
|
||||
},
|
||||
{
|
||||
name: "s390x",
|
||||
name: "s390x",
|
||||
errorExpectedInCentos: true,
|
||||
},
|
||||
{
|
||||
name: "foo-arch",
|
||||
|
|
@ -533,7 +553,7 @@ func TestRhel84_GetArch(t *testing.T) {
|
|||
t.Run(dist.name, func(t *testing.T) {
|
||||
for _, a := range arches {
|
||||
actualArch, err := dist.distro.GetArch(a.name)
|
||||
if a.errorExpected {
|
||||
if a.errorExpected || (a.errorExpectedInCentos && dist.name == "centos") {
|
||||
assert.Nil(t, actualArch)
|
||||
assert.Error(t, err)
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue