Skip to content

Commit d04b7d0

Browse files
achilleas-kthozza
authored andcommitted
distrodefs/fedora: support customizations in container types
Add support for customizations in container types (container and wsl). These are tested in osbuild-composer. These types also support embedding containers.
1 parent 641df82 commit d04b7d0

3 files changed

Lines changed: 32 additions & 43 deletions

File tree

data/distrodefs/fedora/imagetypes.yaml

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,27 @@
806806
- "customizations.services"
807807
- "customizations.timezone"
808808

809+
# supported options for container types (container and wsl)
810+
supported_options_container: &supported_options_container
811+
- "distro"
812+
- "packages"
813+
- "modules"
814+
- "groups"
815+
- "enabled_modules"
816+
- "minimal"
817+
- "containers"
818+
- "customizations.directories"
819+
- "customizations.files"
820+
- "customizations.firewall"
821+
- "customizations.user"
822+
- "customizations.sshkey"
823+
- "customizations.group"
824+
- "customizations.hostname"
825+
- "customizations.locale"
826+
- "customizations.repositories"
827+
- "customizations.services"
828+
- "customizations.timezone"
829+
809830
# options supported by ostree disk (deployment) image types
810831
supported_options_ostree_disk: &supported_options_ostree_disk
811832
- "distro"
@@ -1804,15 +1825,7 @@ image_types:
18041825
- "trousers"
18051826
- "whois-nls"
18061827
- "xkeyboard-config"
1807-
supported_blueprint_options:
1808-
# Only supporting a few basic options for now because we never tested any
1809-
# other customization with this image type
1810-
- "distro"
1811-
- "packages"
1812-
- "modules"
1813-
- "groups"
1814-
- "enabled_modules"
1815-
- "minimal"
1828+
supported_blueprint_options: *supported_options_container
18161829

18171830
wsl:
18181831
# this is the eventual name, and `wsl` the alias but we've been
@@ -1918,15 +1931,7 @@ image_types:
19181931
append:
19191932
exclude:
19201933
- "fuse-libs"
1921-
supported_blueprint_options:
1922-
# Only supporting a few basic options for now because we never tested any
1923-
# other customization with this image type
1924-
- "distro"
1925-
- "packages"
1926-
- "modules"
1927-
- "groups"
1928-
- "enabled_modules"
1929-
- "minimal"
1934+
supported_blueprint_options: *supported_options_container
19301935

19311936
"iot-simplified-installer":
19321937
<<: *rpm_ostree_imgtype_common

pkg/distro/distro_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,10 +638,8 @@ func TestDistro_ManifestFIPSWarning(t *testing.T) {
638638
// functionality which produces different error
639639
// messages. These will be added to RHEL as well soon.
640640
switch imgTypeName {
641-
case "workstation-live-installer":
641+
case "workstation-live-installer", "container", "wsl":
642642
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations.fips: not supported", imgTypeName))
643-
case "wsl", "container":
644-
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations: not supported", imgTypeName))
645643
default:
646644
assert.Equal(t, slices.Contains(warn, msg), !common.IsBuildHostFIPSEnabled(),
647645
"FIPS warning not shown for image: distro='%s', imgTypeName='%s', archName='%s', warn='%v'", distroName, imgTypeName, archName, warn)

pkg/distro/generic/fedora_test.go

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ func TestFedoraDistro_ManifestError(t *testing.T) {
515515
case "iot-raw-xz", "iot-qcow2":
516516
assert.EqualError(t, err, fmt.Sprintf("options validation failed for image type %q: ostree.url: required", imgTypeName))
517517
case "container", "wsl":
518-
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations: not supported", imgTypeName))
518+
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations.kernel: not supported", imgTypeName))
519519
default:
520520
assert.NoError(t, err)
521521
}
@@ -719,10 +719,8 @@ func TestFedoraDistro_CustomFileSystemManifestError(t *testing.T) {
719719
imgType, _ := arch.GetImageType(imgTypeName)
720720
_, _, err := imgType.Manifest(&bp, distro.ImageOptions{OSTree: maybeMakeOSTreeURL(imgTypeName)}, nil, nil)
721721
switch imgTypeName {
722-
case "minimal-installer", "iot-installer", "workstation-live-installer", "iot-simplified-installer", "iot-commit", "iot-container", "iot-bootable-container", "everything-netinst":
722+
case "minimal-installer", "iot-installer", "workstation-live-installer", "iot-simplified-installer", "iot-commit", "iot-container", "iot-bootable-container", "everything-netinst", "container", "wsl":
723723
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations.filesystem: not supported", imgTypeName))
724-
case "container", "wsl":
725-
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations: not supported", imgTypeName))
726724
default:
727725
// TODO: this error message is a bit clunky; bring it more in line with the other messages (remove "The following errors ...")
728726
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: The following custom mountpoints are not supported [\"/etc\"]", imgTypeName))
@@ -750,10 +748,8 @@ func TestFedoraDistro_TestRootMountPoint(t *testing.T) {
750748
imgType, _ := arch.GetImageType(imgTypeName)
751749
_, _, err := imgType.Manifest(&bp, distro.ImageOptions{OSTree: maybeMakeOSTreeURL(imgTypeName)}, nil, nil)
752750
switch imgTypeName {
753-
case "minimal-installer", "workstation-live-installer", "iot-simplified-installer", "iot-installer", "iot-commit", "iot-container", "iot-bootable-container", "everything-netinst":
751+
case "minimal-installer", "workstation-live-installer", "iot-simplified-installer", "iot-installer", "iot-commit", "iot-container", "iot-bootable-container", "everything-netinst", "container", "wsl":
754752
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations.filesystem: not supported", imgTypeName))
755-
case "wsl", "container":
756-
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations: not supported", imgTypeName))
757753
default:
758754
assert.NoError(t, err)
759755
}
@@ -784,10 +780,8 @@ func TestFedoraDistro_CustomFileSystemSubDirectories(t *testing.T) {
784780
imgType, _ := arch.GetImageType(imgTypeName)
785781
_, _, err := imgType.Manifest(&bp, distro.ImageOptions{OSTree: maybeMakeOSTreeURL(imgTypeName)}, nil, nil)
786782
switch imgTypeName {
787-
case "minimal-installer", "workstation-live-installer", "iot-simplified-installer", "iot-installer", "iot-commit", "iot-container", "iot-bootable-container", "everything-netinst":
783+
case "minimal-installer", "workstation-live-installer", "iot-simplified-installer", "iot-installer", "iot-commit", "iot-container", "iot-bootable-container", "everything-netinst", "container", "wsl":
788784
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations.filesystem: not supported", imgTypeName))
789-
case "wsl", "container":
790-
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations: not supported", imgTypeName))
791785
default:
792786
assert.NoError(t, err)
793787
}
@@ -826,10 +820,8 @@ func TestFedoraDistro_MountpointsWithArbitraryDepthAllowed(t *testing.T) {
826820
imgType, _ := arch.GetImageType(imgTypeName)
827821
_, _, err := imgType.Manifest(&bp, distro.ImageOptions{OSTree: maybeMakeOSTreeURL(imgTypeName)}, nil, nil)
828822
switch imgTypeName {
829-
case "minimal-installer", "workstation-live-installer", "iot-simplified-installer", "iot-installer", "iot-commit", "iot-container", "iot-bootable-container", "everything-netinst":
823+
case "minimal-installer", "workstation-live-installer", "iot-simplified-installer", "iot-installer", "iot-commit", "iot-container", "iot-bootable-container", "everything-netinst", "container", "wsl":
830824
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations.filesystem: not supported", imgTypeName))
831-
case "wsl", "container":
832-
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations: not supported", imgTypeName))
833825
default:
834826
assert.NoError(t, err)
835827
}
@@ -864,10 +856,8 @@ func TestFedoraDistro_DirtyMountpointsNotAllowed(t *testing.T) {
864856
imgType, _ := arch.GetImageType(imgTypeName)
865857
_, _, err := imgType.Manifest(&bp, distro.ImageOptions{OSTree: maybeMakeOSTreeURL(imgTypeName)}, nil, nil)
866858
switch imgTypeName {
867-
case "minimal-installer", "workstation-live-installer", "iot-simplified-installer", "iot-installer", "iot-commit", "iot-container", "iot-bootable-container", "everything-netinst":
859+
case "minimal-installer", "workstation-live-installer", "iot-simplified-installer", "iot-installer", "iot-commit", "iot-container", "iot-bootable-container", "everything-netinst", "container", "wsl":
868860
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations.filesystem: not supported", imgTypeName))
869-
case "wsl", "container":
870-
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations: not supported", imgTypeName))
871861
default:
872862
// TODO: this error message is a bit clunky; bring it more in line with the other messages (remove "The following errors ...")
873863
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: The following custom mountpoints are not supported [\"//\" \"/var//\" \"/var//log/audit/\"]", imgTypeName))
@@ -898,10 +888,8 @@ func TestFedoraDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) {
898888
imgType, _ := arch.GetImageType(imgTypeName)
899889
_, _, err := imgType.Manifest(&bp, options, nil, nil)
900890
switch imgTypeName {
901-
case "workstation-live-installer", "iot-container", "iot-commit", "iot-bootable-container", "iot-installer", "iot-simplified-installer", "minimal-installer", "everything-netinst":
891+
case "workstation-live-installer", "iot-container", "iot-commit", "iot-bootable-container", "iot-installer", "iot-simplified-installer", "minimal-installer", "everything-netinst", "container", "wsl":
902892
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations.filesystem: not supported", imgTypeName))
903-
case "wsl", "container":
904-
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations: not supported", imgTypeName))
905893
default:
906894
assert.NoError(t, err)
907895
}
@@ -942,10 +930,8 @@ func TestFedoraDistro_PartitioningConflict(t *testing.T) {
942930
}
943931
_, _, err := imgType.Manifest(&bp, options, nil, nil)
944932
switch imgTypeName {
945-
case "workstation-live-installer", "iot-container", "iot-commit", "iot-bootable-container", "iot-installer", "iot-simplified-installer", "minimal-installer", "everything-netinst":
933+
case "workstation-live-installer", "iot-container", "iot-commit", "iot-bootable-container", "iot-installer", "iot-simplified-installer", "minimal-installer", "everything-netinst", "container", "wsl":
946934
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations.filesystem: not supported", imgTypeName))
947-
case "wsl", "container":
948-
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations: not supported", imgTypeName))
949935
default:
950936
assert.EqualError(t, err, fmt.Sprintf("blueprint validation failed for image type %q: customizations.disk cannot be used with customizations.filesystem", imgTypeName))
951937
}

0 commit comments

Comments
 (0)