Skip to content

Commit

Permalink
disk: unexport AddBootPartition and AddPartitionsForBootMode
Browse files Browse the repository at this point in the history
Those two are not used outside of `disk` so let's unexport them
to keep a smaller API.

Followups, c.f.
osbuild#1041 (comment)
osbuild#1041 (comment)
  • Loading branch information
mvo5 committed Nov 25, 2024
1 parent ac1d26e commit 5e42ce0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions pkg/disk/export_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package disk

var (
PayloadEntityMap = payloadEntityMap
EntityPath = entityPath
PayloadEntityMap = payloadEntityMap
EntityPath = entityPath
AddBootPartition = addBootPartition
AddPartitionsForBootMode = addPartitionsForBootMode
)

func FindDirectoryEntityPath(pt *PartitionTable, path string) []Entity {
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 @@ -996,10 +996,10 @@ func EnsureRootFilesystem(pt *PartitionTable, defaultFsType FSType) error {
return nil
}

// AddBootPartition creates a boot partition. The function will append the boot
// addBootPartition creates a boot partition. The function will append the boot
// partition to the end of the existing partition table therefore it is best to
// call this function early to put boot near the front (as is conventional).
func AddBootPartition(pt *PartitionTable, bootFsType FSType) error {
func addBootPartition(pt *PartitionTable, bootFsType FSType) error {
if bootFsType == FS_NONE {
return fmt.Errorf("error creating boot partition: no filesystem type")
}
Expand Down Expand Up @@ -1034,15 +1034,15 @@ func AddBootPartition(pt *PartitionTable, bootFsType FSType) error {
return nil
}

// AddPartitionsForBootMode creates partitions to satisfy the boot mode requirements:
// addPartitionsForBootMode creates partitions to satisfy the boot mode requirements:
// - BIOS/legacy: adds a 1 MiB BIOS boot partition.
// - UEFI: adds a 200 MiB EFI system partition.
// - Hybrid: adds both.
//
// The function will append the new partitions to the end of the existing
// partition table therefore it is best to call this function early to put them
// near the front (as is conventional).
func AddPartitionsForBootMode(pt *PartitionTable, bootMode platform.BootMode) error {
func addPartitionsForBootMode(pt *PartitionTable, bootMode platform.BootMode) error {
switch bootMode {
case platform.BOOT_LEGACY:
// add BIOS boot partition
Expand Down Expand Up @@ -1185,7 +1185,7 @@ func NewCustomPartitionTable(customizations *blueprint.DiskCustomization, option
}

// TODO: switch to ensure ESP in case customizations already include it
if err := AddPartitionsForBootMode(pt, options.BootMode); err != nil {
if err := addPartitionsForBootMode(pt, options.BootMode); err != nil {
return nil, fmt.Errorf("%s %w", errPrefix, err)
}

Expand All @@ -1203,7 +1203,7 @@ func NewCustomPartitionTable(customizations *blueprint.DiskCustomization, option
if needsBoot(customizations) {
// we need a /boot partition to boot LVM or Btrfs, create boot
// partition if it does not already exist
if err := AddBootPartition(pt, bootFsType); err != nil {
if err := addBootPartition(pt, bootFsType); err != nil {
return nil, fmt.Errorf("%s %w", errPrefix, err)
}
}
Expand Down

0 comments on commit 5e42ce0

Please sign in to comment.