From 4ddd026e7997c4d80c006faceeccfc9ceaa653f9 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 18 Nov 2024 18:06:12 +0100 Subject: [PATCH] disk: update for new MinSize type --- pkg/disk/disk_test.go | 4 ++-- pkg/disk/partition_table.go | 12 ++++++------ pkg/distro/fedora/imagetype.go | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/disk/disk_test.go b/pkg/disk/disk_test.go index 0f6d9d2787..ff92d09415 100644 --- a/pkg/disk/disk_test.go +++ b/pkg/disk/disk_test.go @@ -146,7 +146,7 @@ func blueprintApplied(pt *disk.PartitionTable, bp []blueprint.FilesystemCustomiz } for idx, ent := range path { if sz, ok := ent.(disk.Sizeable); ok { - if sz.GetSize() < mnt.MinSize { + if sz.GetSize() < mnt.MinSize.Uint64() { return fmt.Errorf("entity %d in the path from %s is smaller (%d) than the requested minsize %d", idx, mnt.Mountpoint, sz.GetSize(), mnt.MinSize) } } @@ -178,7 +178,7 @@ func TestCreatePartitionTable(t *testing.T) { sumSizes := func(bp []blueprint.FilesystemCustomization) (sum uint64) { for _, mnt := range bp { - sum += mnt.MinSize + sum += mnt.MinSize.Uint64() } return sum } diff --git a/pkg/disk/partition_table.go b/pkg/disk/partition_table.go index 9bed8eb611..c9fec6a905 100644 --- a/pkg/disk/partition_table.go +++ b/pkg/disk/partition_table.go @@ -428,7 +428,7 @@ func (pt *PartitionTable) applyCustomization(mountpoints []blueprint.FilesystemC newMountpoints := []blueprint.FilesystemCustomization{} for _, mnt := range mountpoints { - size := clampFSSize(mnt.Mountpoint, mnt.MinSize) + size := clampFSSize(mnt.Mountpoint, mnt.MinSize.Uint64()) if path := entityPath(pt, mnt.Mountpoint); len(path) != 0 { size = alignEntityBranch(path, size) resizeEntityBranch(path, size) @@ -1237,7 +1237,7 @@ func NewCustomPartitionTable(customizations *blueprint.DiskCustomization, option pt.EnsureDirectorySizes(options.RequiredMinSizes) } - pt.relayout(customizations.MinSize) + pt.relayout(customizations.MinSize.Uint64()) pt.GenerateUUIDs(rng) return pt, nil @@ -1260,7 +1260,7 @@ func addPlainPartition(pt *PartitionTable, partition blueprint.PartitionCustomiz newpart := Partition{ Type: partType, Bootable: false, - Size: partition.MinSize, + Size: partition.MinSize.Uint64(), Payload: &Filesystem{ Type: fstype, Label: partition.Label, @@ -1310,7 +1310,7 @@ func addLVMPartition(pt *PartitionTable, partition blueprint.PartitionCustomizat Mountpoint: lv.Mountpoint, FSTabOptions: "defaults", // TODO: add customization } - if _, err := newvg.CreateLogicalVolume(lv.Name, lv.MinSize, newfs); err != nil { + if _, err := newvg.CreateLogicalVolume(lv.Name, lv.MinSize.Uint64(), newfs); err != nil { return fmt.Errorf("error creating logical volume %q (%s): %w", lv.Name, lv.Mountpoint, err) } } @@ -1318,7 +1318,7 @@ func addLVMPartition(pt *PartitionTable, partition blueprint.PartitionCustomizat // create partition for volume group newpart := Partition{ Type: LVMPartitionGUID, - Size: partition.MinSize, + Size: partition.MinSize.Uint64(), Bootable: false, Payload: newvg, } @@ -1345,7 +1345,7 @@ func addBtrfsPartition(pt *PartitionTable, partition blueprint.PartitionCustomiz Type: FilesystemDataGUID, Bootable: false, Payload: newvol, - Size: partition.MinSize, + Size: partition.MinSize.Uint64(), } pt.Partitions = append(pt.Partitions, newpart) diff --git a/pkg/distro/fedora/imagetype.go b/pkg/distro/fedora/imagetype.go index 60aea17cf7..b06b304444 100644 --- a/pkg/distro/fedora/imagetype.go +++ b/pkg/distro/fedora/imagetype.go @@ -155,7 +155,7 @@ func (t *imageType) getPartitionTable( if options.Size > 0 { // user specified a size on the command line, so let's override the // customization with the calculated/rounded imageSize - partitioning.MinSize = imageSize + partitioning.MinSize = datasizes.Size(imageSize) } partOptions := &disk.CustomPartitionTableOptions{