-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
osbuild,internal: create new MakeFakePartitionTable helper
Both the osbuild and the image package need/will need a helper to make fake partition tables. So this creates a new `testdisk` package that contains a helper for this. It can not be part of the existing `test` package because of circular imports.
- Loading branch information
1 parent
537ead4
commit b4905b5
Showing
3 changed files
with
40 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package testdisk | ||
|
||
import ( | ||
"github.com/osbuild/images/pkg/disk" | ||
) | ||
|
||
// MakeFakePartitionTable is a helper to create partition table structs | ||
// for tests. It uses sensible defaults for common scenarios. | ||
func MakeFakePartitionTable(mntPoints ...string) *disk.PartitionTable { | ||
var partitions []disk.Partition | ||
for _, mntPoint := range mntPoints { | ||
payload := &disk.Filesystem{ | ||
Type: "ext4", | ||
Mountpoint: mntPoint, | ||
} | ||
switch mntPoint { | ||
case "/": | ||
payload.UUID = disk.RootPartitionUUID | ||
case "/boot/efi": | ||
payload.UUID = disk.EFIFilesystemUUID | ||
payload.Type = "vfat" | ||
default: | ||
payload.UUID = disk.FilesystemDataUUID | ||
} | ||
partitions = append(partitions, disk.Partition{ | ||
Payload: payload, | ||
}) | ||
|
||
} | ||
return &disk.PartitionTable{ | ||
Type: "gpt", | ||
Partitions: partitions, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters