Skip to content

Commit

Permalink
image: run ValidateLayoutConstraints() when using DiskCustomizations
Browse files Browse the repository at this point in the history
This commit will run ValidateLayoutConstraints() when a `DiskCustomization`
is used.
  • Loading branch information
mvo5 committed Nov 25, 2024
1 parent 60169e7 commit 6705447
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bib/cmd/bootc-image-builder/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ func genPartitionTable(c *ManifestConfig, customizations *blueprint.Customizatio
}

func genPartitionTableDiskCust(c *ManifestConfig, diskCust *blueprint.DiskCustomization, rng *rand.Rand) (*disk.PartitionTable, error) {
if err := diskCust.ValidateLayoutConstraints(); err != nil {
return nil, fmt.Errorf("cannot use disk customization: %w", err)
}

diskCust.MinSize = max(diskCust.MinSize, c.RootfsMinsize)

basept, ok := partitionTables[c.Architecture.String()]
Expand Down
25 changes: 25 additions & 0 deletions bib/cmd/bootc-image-builder/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,3 +423,28 @@ func TestGenPartitionTableSetsRootfsForAllFilesystemsBtrfs(t *testing.T) {
mnt, _ = findMountableSizeableFor(pt, "/boot/efi")
assert.Equal(t, "vfat", mnt.GetFSType())
}

func TestGenPartitionTableDiskCustomizationRunsValidateLayoutConstraints(t *testing.T) {
rng := bib.CreateRand()

cnf := &bib.ManifestConfig{
Architecture: arch.FromString("amd64"),
RootFSType: "xfs",
}
cus := &blueprint.Customizations{
Disk: &blueprint.DiskCustomization{
Partitions: []blueprint.PartitionCustomization{
{
Type: "lvm",
VGCustomization: blueprint.VGCustomization{},
},
{
Type: "lvm",
VGCustomization: blueprint.VGCustomization{},
},
},
},
}
_, err := bib.GenPartitionTable(cnf, cus, rng)
assert.EqualError(t, err, "cannot use disk customization: multiple LVM volume groups are not yet supported")
}

0 comments on commit 6705447

Please sign in to comment.