Skip to content

Commit

Permalink
distro: run ValidateLayoutConstraints() when using PartitionCustomi…
Browse files Browse the repository at this point in the history
…zations

This commit will run `ValidateLayoutConstraints()` when a `DiskCustomization`
is used.
  • Loading branch information
mvo5 authored and achilleas-k committed Nov 25, 2024
1 parent 42f6bab commit 36d86e4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
37 changes: 37 additions & 0 deletions pkg/distro/fedora/distro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1032,3 +1032,40 @@ func TestDistroFactory(t *testing.T) {
})
}
}

func TestDistro_DiskCustomizationRunsValidateLayoutConstraints(t *testing.T) {
bp := blueprint.Blueprint{
Customizations: &blueprint.Customizations{
Disk: &blueprint.DiskCustomization{
Partitions: []blueprint.PartitionCustomization{
{
Type: "lvm",
VGCustomization: blueprint.VGCustomization{},
},
{
Type: "lvm",
VGCustomization: blueprint.VGCustomization{},
},
},
},
},
}

for _, dist := range fedoraFamilyDistros {
fedoraDistro := dist.distro
for _, archName := range fedoraDistro.ListArches() {
arch, err := fedoraDistro.GetArch(archName)
assert.NoError(t, err)
imgType, err := arch.GetImageType("qcow2")
assert.NoError(t, err, archName)
t.Run(fmt.Sprintf("%s/%s", archName, imgType.Name()), func(t *testing.T) {
imgType, _ := arch.GetImageType(imgType.Name())
imgOpts := distro.ImageOptions{
Size: imgType.Size(0),
}
_, _, err := imgType.Manifest(&bp, imgOpts, nil, 0)
assert.EqualError(t, err, "cannot use disk customization: multiple LVM volume groups are not yet supported")
})
}
}
}
8 changes: 8 additions & 0 deletions pkg/distro/fedora/imagetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,5 +468,13 @@ func (t *imageType) checkOptions(bp *blueprint.Blueprint, options distro.ImageOp
}
}

diskc, err := customizations.GetPartitioning()
if err != nil {
return nil, err
}
if err := diskc.ValidateLayoutConstraints(); err != nil {
return nil, fmt.Errorf("cannot use disk customization: %w", err)
}

return nil, nil
}

0 comments on commit 36d86e4

Please sign in to comment.