fedora: make fedora-iot-... names the aliases

Remove the 'fedora' prefix from the canonical name for fedora-iot image
types.  Make the previous names aliases.
This has little functional change since we're simply swapping the
canonical name with an existing alias.
This commit is contained in:
Achilleas Koutsou 2022-09-19 16:47:41 +02:00 committed by Ondřej Budai
parent 434362e81e
commit f9c37a167a
2 changed files with 66 additions and 95 deletions

View file

@ -71,8 +71,8 @@ var (
// Image Definitions // Image Definitions
iotCommitImgType = imageType{ iotCommitImgType = imageType{
name: "fedora-iot-commit", name: "iot-commit",
nameAliases: []string{"iot-commit"}, nameAliases: []string{"fedora-iot-commit"},
filename: "commit.tar", filename: "commit.tar",
mimeType: "application/x-tar", mimeType: "application/x-tar",
packageSets: map[string]packageSetFunc{ packageSets: map[string]packageSetFunc{
@ -89,8 +89,8 @@ var (
} }
iotOCIImgType = imageType{ iotOCIImgType = imageType{
name: "fedora-iot-container", name: "iot-container",
nameAliases: []string{"iot-container"}, nameAliases: []string{"fedora-iot-container"},
filename: "container.tar", filename: "container.tar",
mimeType: "application/x-tar", mimeType: "application/x-tar",
packageSets: map[string]packageSetFunc{ packageSets: map[string]packageSetFunc{
@ -111,8 +111,8 @@ var (
} }
iotInstallerImgType = imageType{ iotInstallerImgType = imageType{
name: "fedora-iot-installer", name: "iot-installer",
nameAliases: []string{"iot-installer"}, nameAliases: []string{"fedora-iot-installer"},
filename: "installer.iso", filename: "installer.iso",
mimeType: "application/x-iso9660-image", mimeType: "application/x-iso9660-image",
packageSets: map[string]packageSetFunc{ packageSets: map[string]packageSetFunc{
@ -131,8 +131,8 @@ var (
} }
iotRawImgType = imageType{ iotRawImgType = imageType{
name: "fedora-iot-raw-image", name: "iot-raw-image",
nameAliases: []string{"iot-raw-image"}, nameAliases: []string{"fedora-iot-raw-image"},
filename: "image.raw.xz", filename: "image.raw.xz",
mimeType: "application/xz", mimeType: "application/xz",
packageSets: map[string]packageSetFunc{}, packageSets: map[string]packageSetFunc{},
@ -681,7 +681,7 @@ func (t *imageType) checkOptions(customizations *blueprint.Customizations, optio
return fmt.Errorf("boot ISO image type %q requires specifying a URL from which to retrieve the OSTree commit", t.name) return fmt.Errorf("boot ISO image type %q requires specifying a URL from which to retrieve the OSTree commit", t.name)
} }
if t.name == "iot-installer" || t.name == "fedora-iot-installer" { if t.name == "iot-installer" {
allowed := []string{"User", "Group"} allowed := []string{"User", "Group"}
if err := customizations.CheckAllowed(allowed...); err != nil { if err := customizations.CheckAllowed(allowed...); err != nil {
return fmt.Errorf("unsupported blueprint customizations found for boot ISO image type %q: (allowed: %s)", t.name, strings.Join(allowed, ", ")) return fmt.Errorf("unsupported blueprint customizations found for boot ISO image type %q: (allowed: %s)", t.name, strings.Join(allowed, ", "))

View file

@ -92,40 +92,6 @@ func TestFilenameFromType(t *testing.T) {
mimeType: "application/x-vmdk", mimeType: "application/x-vmdk",
}, },
}, },
{
name: "iot-commit",
args: args{"iot-commit"},
want: wantResult{
filename: "commit.tar",
mimeType: "application/x-tar",
},
},
// Alias
{
name: "fedora-iot-commit",
args: args{"fedora-iot-commit"},
want: wantResult{
filename: "commit.tar",
mimeType: "application/x-tar",
},
},
{
name: "fedora-iot-commit",
args: args{"fedora-iot-commit"},
want: wantResult{
filename: "commit.tar",
mimeType: "application/x-tar",
},
},
{
name: "fedora-iot-container",
args: args{"fedora-iot-container"},
want: wantResult{
filename: "container.tar",
mimeType: "application/x-tar",
},
},
{ {
name: "container", name: "container",
args: args{"container"}, args: args{"container"},
@ -134,7 +100,22 @@ func TestFilenameFromType(t *testing.T) {
mimeType: "application/x-tar", mimeType: "application/x-tar",
}, },
}, },
// Alias {
name: "iot-commit",
args: args{"iot-commit"},
want: wantResult{
filename: "commit.tar",
mimeType: "application/x-tar",
},
},
{ // Alias
name: "fedora-iot-commit",
args: args{"fedora-iot-commit"},
want: wantResult{
filename: "commit.tar",
mimeType: "application/x-tar",
},
},
{ {
name: "iot-container", name: "iot-container",
args: args{"iot-container"}, args: args{"iot-container"},
@ -143,7 +124,7 @@ func TestFilenameFromType(t *testing.T) {
mimeType: "application/x-tar", mimeType: "application/x-tar",
}, },
}, },
{ { // Alias
name: "fedora-iot-container", name: "fedora-iot-container",
args: args{"fedora-iot-container"}, args: args{"fedora-iot-container"},
want: wantResult{ want: wantResult{
@ -151,16 +132,6 @@ func TestFilenameFromType(t *testing.T) {
mimeType: "application/x-tar", mimeType: "application/x-tar",
}, },
}, },
{
name: "fedora-iot-installer",
args: args{"fedora-iot-installer"},
want: wantResult{
filename: "installer.iso",
mimeType: "application/x-iso9660-image",
},
},
// Alias
{ {
name: "iot-installer", name: "iot-installer",
args: args{"iot-installer"}, args: args{"iot-installer"},
@ -169,7 +140,7 @@ func TestFilenameFromType(t *testing.T) {
mimeType: "application/x-iso9660-image", mimeType: "application/x-iso9660-image",
}, },
}, },
{ { // Alias
name: "fedora-iot-installer", name: "fedora-iot-installer",
args: args{"fedora-iot-installer"}, args: args{"fedora-iot-installer"},
want: wantResult{ want: wantResult{
@ -274,10 +245,10 @@ func TestImageType_Name(t *testing.T) {
"vhd", "vhd",
"vmdk", "vmdk",
"ami", "ami",
"fedora-iot-commit", "iot-commit",
"fedora-iot-container", "iot-container",
"fedora-iot-installer", "iot-installer",
"fedora-iot-raw-image", "iot-raw-image",
"oci", "oci",
}, },
}, },
@ -288,10 +259,10 @@ func TestImageType_Name(t *testing.T) {
"openstack", "openstack",
"ami", "ami",
"oci", "oci",
"fedora-iot-commit", "iot-commit",
"fedora-iot-container", "iot-container",
"fedora-iot-installer", "iot-installer",
"fedora-iot-raw-image", "iot-raw-image",
}, },
}, },
} }
@ -305,7 +276,7 @@ func TestImageType_Name(t *testing.T) {
arch, err := dist.distro.GetArch(mapping.arch) arch, err := dist.distro.GetArch(mapping.arch)
if assert.NoError(t, err) { if assert.NoError(t, err) {
for _, imgName := range mapping.imgNames { for _, imgName := range mapping.imgNames {
if imgName == "fedora-iot-commit" { if imgName == "iot-commit" {
continue continue
} }
imgType, err := arch.GetImageType(imgName) imgType, err := arch.GetImageType(imgName)
@ -332,32 +303,32 @@ func TestImageTypeAliases(t *testing.T) {
want wantResult want wantResult
}{ }{
{ {
name: "fedora-iot-commit aliases", name: "iot-commit aliases",
args: args{ args: args{
imageTypeAliases: []string{"iot-commit"}, imageTypeAliases: []string{"fedora-iot-commit"},
}, },
want: wantResult{ want: wantResult{
imageTypeName: "fedora-iot-commit", imageTypeName: "iot-commit",
}, },
}, },
{ {
name: "fedora-iot-container aliases", name: "iot-container aliases",
args: args{ args: args{
imageTypeAliases: []string{"iot-container"}, imageTypeAliases: []string{"fedora-iot-container"},
}, },
want: wantResult{ want: wantResult{
imageTypeName: "fedora-iot-container", imageTypeName: "iot-container",
}, },
}, },
{ {
name: "fedora-iot-installer aliases", name: "iot-installer aliases",
args: args{ args: args{
imageTypeAliases: []string{"iot-installer"}, imageTypeAliases: []string{"fedora-iot-installer"},
}, },
want: wantResult{ want: wantResult{
imageTypeName: "fedora-iot-installer", imageTypeName: "iot-installer",
}, },
}, },
} }
@ -419,9 +390,9 @@ func TestDistro_ManifestError(t *testing.T) {
} }
testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType)
_, err := imgType.Manifest(bp.Customizations, imgOpts, nil, testPackageSpecSets, nil, 0) _, err := imgType.Manifest(bp.Customizations, imgOpts, nil, testPackageSpecSets, nil, 0)
if imgTypeName == "fedora-iot-commit" || imgTypeName == "fedora-iot-container" || imgTypeName == "fedora-iot-raw-image" { if imgTypeName == "iot-commit" || imgTypeName == "iot-container" || imgTypeName == "iot-raw-image" {
assert.EqualError(t, err, "kernel boot parameter customizations are not supported for ostree types") assert.EqualError(t, err, "kernel boot parameter customizations are not supported for ostree types")
} else if imgTypeName == "fedora-iot-installer" { } else if imgTypeName == "iot-installer" {
assert.EqualError(t, err, fmt.Sprintf("boot ISO image type \"%s\" requires specifying a URL from which to retrieve the OSTree commit", imgTypeName)) assert.EqualError(t, err, fmt.Sprintf("boot ISO image type \"%s\" requires specifying a URL from which to retrieve the OSTree commit", imgTypeName))
} else { } else {
assert.NoError(t, err) assert.NoError(t, err)
@ -444,10 +415,10 @@ func TestArchitecture_ListImageTypes(t *testing.T) {
"vhd", "vhd",
"vmdk", "vmdk",
"ami", "ami",
"fedora-iot-commit", "iot-commit",
"fedora-iot-container", "iot-container",
"fedora-iot-installer", "iot-installer",
"fedora-iot-raw-image", "iot-raw-image",
"oci", "oci",
"container", "container",
}, },
@ -458,10 +429,10 @@ func TestArchitecture_ListImageTypes(t *testing.T) {
"qcow2", "qcow2",
"openstack", "openstack",
"ami", "ami",
"fedora-iot-commit", "iot-commit",
"fedora-iot-container", "iot-container",
"fedora-iot-installer", "iot-installer",
"fedora-iot-raw-image", "iot-raw-image",
"oci", "oci",
"container", "container",
}, },
@ -555,9 +526,9 @@ func TestDistro_CustomFileSystemManifestError(t *testing.T) {
for _, imgTypeName := range arch.ListImageTypes() { for _, imgTypeName := range arch.ListImageTypes() {
imgType, _ := arch.GetImageType(imgTypeName) imgType, _ := arch.GetImageType(imgTypeName)
_, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0)
if imgTypeName == "fedora-iot-commit" || imgTypeName == "fedora-iot-container" || imgTypeName == "fedora-iot-raw-image" { if imgTypeName == "iot-commit" || imgTypeName == "iot-container" || imgTypeName == "iot-raw-image" {
assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types")
} else if imgTypeName == "fedora-iot-installer" { } else if imgTypeName == "iot-installer" {
continue continue
} else { } else {
assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/etc\"]") assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/etc\"]")
@ -584,9 +555,9 @@ func TestDistro_TestRootMountPoint(t *testing.T) {
imgType, _ := arch.GetImageType(imgTypeName) imgType, _ := arch.GetImageType(imgTypeName)
testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType)
_, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0)
if imgTypeName == "fedora-iot-commit" || imgTypeName == "fedora-iot-container" || imgTypeName == "fedora-iot-raw-image" { if imgTypeName == "iot-commit" || imgTypeName == "iot-container" || imgTypeName == "iot-raw-image" {
assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types")
} else if imgTypeName == "fedora-iot-installer" { } else if imgTypeName == "iot-installer" {
continue continue
} else { } else {
assert.NoError(t, err) assert.NoError(t, err)
@ -617,7 +588,7 @@ func TestDistro_CustomFileSystemSubDirectories(t *testing.T) {
imgType, _ := arch.GetImageType(imgTypeName) imgType, _ := arch.GetImageType(imgTypeName)
testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType)
_, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0)
if strings.HasPrefix(imgTypeName, "fedora-iot-") { if strings.HasPrefix(imgTypeName, "iot-") {
continue continue
} else { } else {
assert.NoError(t, err) assert.NoError(t, err)
@ -656,7 +627,7 @@ func TestDistro_MountpointsWithArbitraryDepthAllowed(t *testing.T) {
imgType, _ := arch.GetImageType(imgTypeName) imgType, _ := arch.GetImageType(imgTypeName)
testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType)
_, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0)
if strings.HasPrefix(imgTypeName, "fedora-iot-") { if strings.HasPrefix(imgTypeName, "iot-") {
continue continue
} else { } else {
assert.NoError(t, err) assert.NoError(t, err)
@ -690,7 +661,7 @@ func TestDistro_DirtyMountpointsNotAllowed(t *testing.T) {
for _, imgTypeName := range arch.ListImageTypes() { for _, imgTypeName := range arch.ListImageTypes() {
imgType, _ := arch.GetImageType(imgTypeName) imgType, _ := arch.GetImageType(imgTypeName)
_, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0)
if strings.HasPrefix(imgTypeName, "fedora-iot-") { if strings.HasPrefix(imgTypeName, "iot-") {
continue continue
} else { } else {
assert.EqualError(t, err, "The following custom mountpoints are not supported [\"//\" \"/var//\" \"/var//log/audit/\"]") assert.EqualError(t, err, "The following custom mountpoints are not supported [\"//\" \"/var//\" \"/var//log/audit/\"]")
@ -720,9 +691,9 @@ func TestDistro_CustomFileSystemPatternMatching(t *testing.T) {
for _, imgTypeName := range arch.ListImageTypes() { for _, imgTypeName := range arch.ListImageTypes() {
imgType, _ := arch.GetImageType(imgTypeName) imgType, _ := arch.GetImageType(imgTypeName)
_, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0)
if imgTypeName == "fedora-iot-commit" || imgTypeName == "fedora-iot-container" || imgTypeName == "fedora-iot-raw-image" { if imgTypeName == "iot-commit" || imgTypeName == "iot-container" || imgTypeName == "iot-raw-image" {
assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types")
} else if imgTypeName == "fedora-iot-installer" { } else if imgTypeName == "iot-installer" {
continue continue
} else { } else {
assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/variable\" \"/variable/log/audit\"]") assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/variable\" \"/variable/log/audit\"]")
@ -749,9 +720,9 @@ func TestDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) {
imgType, _ := arch.GetImageType(imgTypeName) imgType, _ := arch.GetImageType(imgTypeName)
testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType)
_, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0)
if imgTypeName == "fedora-iot-commit" || imgTypeName == "fedora-iot-container" || imgTypeName == "fedora-iot-raw-image" { if imgTypeName == "iot-commit" || imgTypeName == "iot-container" || imgTypeName == "iot-raw-image" {
assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types")
} else if imgTypeName == "fedora-iot-installer" { } else if imgTypeName == "iot-installer" {
continue continue
} else { } else {
assert.NoError(t, err) assert.NoError(t, err)