From 569304591611cdcd7e54cb8cd9a7e8a3cde03d38 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Wed, 10 Nov 2021 15:30:49 +0100 Subject: [PATCH] disk: createPartition now appends also it It makes sense that the function that creates the partition also adds it to the partition table. --- internal/disk/customizations.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/internal/disk/customizations.go b/internal/disk/customizations.go index 265a55c00..100ff5fee 100644 --- a/internal/disk/customizations.go +++ b/internal/disk/customizations.go @@ -40,8 +40,7 @@ func CreatePartitionTable( for _, m := range mountpoints { if m.Mountpoint != "/" { partitionSize := m.MinSize / sectorSize - partition := basePartitionTable.createPartition(m.Mountpoint, partitionSize, rng) - basePartitionTable.Partitions = append(basePartitionTable.Partitions, partition) + basePartitionTable.createPartition(m.Mountpoint, partitionSize, rng) } } @@ -64,7 +63,7 @@ func CreatePartitionTable( return basePartitionTable } -func (pt *PartitionTable) createPartition(mountpoint string, size uint64, rng *rand.Rand) Partition { +func (pt *PartitionTable) createPartition(mountpoint string, size uint64, rng *rand.Rand) { filesystem := Filesystem{ Type: "xfs", UUID: uuid.Must(newRandomUUIDFromReader(rng)).String(), @@ -73,18 +72,18 @@ func (pt *PartitionTable) createPartition(mountpoint string, size uint64, rng *r FSTabFreq: 0, FSTabPassNo: 0, } - if pt.Type != "gpt" { - return Partition{ - Size: size, - Filesystem: &filesystem, - } - } - return Partition{ + + partition := Partition{ Size: size, - Type: FilesystemDataGUID, - UUID: uuid.Must(newRandomUUIDFromReader(rng)).String(), Filesystem: &filesystem, } + + if pt.Type == "gpt" { + partition.Type = FilesystemDataGUID + partition.UUID = uuid.Must(newRandomUUIDFromReader(rng)).String() + } + + pt.Partitions = append(pt.Partitions, partition) } func newRandomUUIDFromReader(r io.Reader) (uuid.UUID, error) {