Skip to content

Commit

Permalink
disk: update for new MinSize type
Browse files Browse the repository at this point in the history
  • Loading branch information
mvo5 committed Nov 21, 2024
1 parent d08a854 commit 4ddd026
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pkg/disk/disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/disk/partition_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -1310,15 +1310,15 @@ 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)
}
}

// create partition for volume group
newpart := Partition{
Type: LVMPartitionGUID,
Size: partition.MinSize,
Size: partition.MinSize.Uint64(),
Bootable: false,
Payload: newvg,
}
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/distro/fedora/imagetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 4ddd026

Please sign in to comment.