Skip to content

Commit

Permalink
Add additional device naming formats to formatPartition func:
Browse files Browse the repository at this point in the history
This allows for using the formatPartition func for more
device types. `vd*` is a device created by virtio.
`hd*` for legacy IDE hard disks.

Signed-off-by: Jacob Weinstock <[email protected]>
  • Loading branch information
jacobweinstock committed Jul 17, 2023
1 parent e79eb4d commit 7b5ba2b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/workflow/template_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ var templateFuncs = map[string]interface{}{
//
// formatPartition("/dev/nvme0n1", 0) -> /dev/nvme0n1p1
// formatPartition("/dev/sda", 1) -> /dev/sda1
// formatPartition("/dev/vda", 2) -> /dev/vda2
func formatPartition(dev string, partition int) string {
switch {
case strings.HasPrefix(dev, "/dev/nvme"):
return fmt.Sprintf("%vp%v", dev, partition)
case strings.HasPrefix(dev, "/dev/sd"):
case strings.HasPrefix(dev, "/dev/sd"), strings.HasPrefix(dev, "/dev/vd"), strings.HasPrefix(dev, "/dev/hd"):
return fmt.Sprintf("%v%v", dev, partition)
}
return dev
Expand Down

0 comments on commit 7b5ba2b

Please sign in to comment.