Commit graph

10 commits

Author SHA1 Message Date
Christian Kellner
ca61baf03b disk: add partition type helpers
Add helper methods on `Partition` so that we can easily "detect" if
they are of the type BIOS-BOOT or PReP. Add the PReP GUID for GPT
as well.
2022-02-27 22:03:36 +01:00
Christian Kellner
d1b1e32b6e disk: Partition.Payload is now an Entity
Partition.Payload now supports every type of disk.Entity which enables
creating PartitionTables with LUKS, LVM, and Btrfs. \o/

Co-Authored-By: Achilleas Koutsou <achilleas@koutsou.net>
2022-02-22 19:23:41 +00:00
Christian Kellner
206e030f2c disk: guard against nil pointer dereferencing
Add guards protecting against dereferencing the pointer receiver of
method calls.

Co-Authored-By: Achilleas Koutsou <achilleas@koutsou.net>
2022-02-22 19:23:41 +00:00
Achilleas Koutsou
3110ae4629 disk: move stage option generation functions to osbuild1,2
Co-Authored-By: Christian Kellner <christian@kellner.me>
2022-02-22 19:23:41 +00:00
Achilleas Koutsou
54fd090a60 disk: rename Partition.Filesystem to Payload
A Partition can contain any type of Entity now.  Before we change the
type, rename the field to a more generic term.
2022-02-22 19:23:41 +00:00
Achilleas Koutsou
221cdedebc disk: Entity types must implement Clone()
All disk.Entitity types now implement Clone() which should return a
deep copy of the same object. Add the Clone() method to the entity
interface. The return type is Entity, but callers can assume it's
safe to convert back to the original type.

Co-Authored-By: Christian Kellner <christian@kellner.me>
2022-02-22 19:23:41 +00:00
Christian Kellner
4c34b5e2a8 disk: implement Sizeable interface for PartitionTable and Partition
In our model a partition table has a size to represent the disk size.
Also each individual partition has a size, so they both implement the
Sizeable interface.

Co-Authored-By: Achilleas Koutsou <achilleas@koutsou.net>
2022-02-22 19:23:41 +00:00
Achilleas Koutsou
0e1c769598 disk: implement Container interface for PartitionTable and Partition
A `PartitionTable` is a container for one or more instances of
`Partition`, which itself might contain a `Filesystem`.

Co-Authored-By: Christian Kellner <christian@kellner.me>
2022-02-22 19:23:41 +00:00
Christian Kellner
51a396e3f1 disk: implement Entity interface
Implement the base type of the new entity system, i.e. `Entity`,
for all relevant components:
 - PartitionTable
 - Partition
 - Filesystem

Co-Authored-By: Achilleas Koutsou <achilleas@koutsou.net>
2022-02-22 19:23:41 +00:00
Achilleas Koutsou
22b8b671a8 disk: move Partition and methods to separate file
Split up disk.go into smaller more manageable pieces: finish
by moving `Partition` to its own file.

Co-Authored-By: Christian Kellner <christian@kellner.me>
2022-02-22 19:23:41 +00:00