distro/fedora: restrict allowed 'iot-raw-image' type customizations
Previously, the rest was mostly silently ignored without errors. Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
parent
76cbec2149
commit
9ab20f72b0
2 changed files with 23 additions and 5 deletions
|
|
@ -795,6 +795,14 @@ func (t *imageType) checkOptions(customizations *blueprint.Customizations, optio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if t.name == "iot-raw-image" {
|
||||||
|
allowed := []string{"User", "Group", "Directories", "Files", "Services"}
|
||||||
|
if err := customizations.CheckAllowed(allowed...); err != nil {
|
||||||
|
return nil, fmt.Errorf("unsupported blueprint customizations found for image type %q: (allowed: %s)", t.name, strings.Join(allowed, ", "))
|
||||||
|
}
|
||||||
|
// TODO: consider additional checks, such as those in "edge-simplified-installer" in RHEL distros
|
||||||
|
}
|
||||||
|
|
||||||
// BootISO's have limited support for customizations.
|
// BootISO's have limited support for customizations.
|
||||||
// TODO: Support kernel name selection for image-installer
|
// TODO: Support kernel name selection for image-installer
|
||||||
if t.bootISO {
|
if t.bootISO {
|
||||||
|
|
|
||||||
|
|
@ -418,12 +418,14 @@ 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 == "iot-commit" || imgTypeName == "iot-container" || imgTypeName == "iot-raw-image" {
|
if imgTypeName == "iot-commit" || imgTypeName == "iot-container" {
|
||||||
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 == "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 if imgTypeName == "image-installer" {
|
} else if imgTypeName == "image-installer" {
|
||||||
assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for boot ISO image type \"%s\": (allowed: User, Group)", imgTypeName))
|
assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for boot ISO image type \"%s\": (allowed: User, Group)", imgTypeName))
|
||||||
|
} else if imgTypeName == "iot-raw-image" {
|
||||||
|
assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for image type %q: (allowed: User, Group, Directories, Files, Services)", imgTypeName))
|
||||||
} else {
|
} else {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
@ -565,8 +567,10 @@ 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 == "iot-commit" || imgTypeName == "iot-container" || imgTypeName == "iot-raw-image" {
|
if imgTypeName == "iot-commit" || imgTypeName == "iot-container" {
|
||||||
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 == "iot-raw-image" {
|
||||||
|
assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for image type %q: (allowed: User, Group, Directories, Files, Services)", imgTypeName))
|
||||||
} else if imgTypeName == "iot-installer" || imgTypeName == "image-installer" {
|
} else if imgTypeName == "iot-installer" || imgTypeName == "image-installer" {
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -594,8 +598,10 @@ 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 == "iot-commit" || imgTypeName == "iot-container" || imgTypeName == "iot-raw-image" {
|
if imgTypeName == "iot-commit" || imgTypeName == "iot-container" {
|
||||||
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 == "iot-raw-image" {
|
||||||
|
assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for image type %q: (allowed: User, Group, Directories, Files, Services)", imgTypeName))
|
||||||
} else if imgTypeName == "iot-installer" || imgTypeName == "image-installer" {
|
} else if imgTypeName == "iot-installer" || imgTypeName == "image-installer" {
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -730,8 +736,10 @@ 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 == "iot-commit" || imgTypeName == "iot-container" || imgTypeName == "iot-raw-image" {
|
if imgTypeName == "iot-commit" || imgTypeName == "iot-container" {
|
||||||
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 == "iot-raw-image" {
|
||||||
|
assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for image type %q: (allowed: User, Group, Directories, Files, Services)", imgTypeName))
|
||||||
} else if imgTypeName == "iot-installer" || imgTypeName == "image-installer" {
|
} else if imgTypeName == "iot-installer" || imgTypeName == "image-installer" {
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -759,8 +767,10 @@ 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 == "iot-commit" || imgTypeName == "iot-container" || imgTypeName == "iot-raw-image" {
|
if imgTypeName == "iot-commit" || imgTypeName == "iot-container" {
|
||||||
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 == "iot-raw-image" {
|
||||||
|
assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for image type %q: (allowed: User, Group, Directories, Files, Services)", imgTypeName))
|
||||||
} else if imgTypeName == "iot-installer" || imgTypeName == "image-installer" {
|
} else if imgTypeName == "iot-installer" || imgTypeName == "image-installer" {
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue