diff --git a/internal/distro/rhel85/stage_options.go b/internal/distro/rhel85/stage_options.go index 39c8970b0..ace61a724 100644 --- a/internal/distro/rhel85/stage_options.go +++ b/internal/distro/rhel85/stage_options.go @@ -5,6 +5,7 @@ import ( "path/filepath" "github.com/google/uuid" + "github.com/osbuild/osbuild-composer/internal/blueprint" "github.com/osbuild/osbuild-composer/internal/crypt" "github.com/osbuild/osbuild-composer/internal/disk" @@ -383,7 +384,7 @@ func sfdiskStageOptions(pt *disk.PartitionTable, device *osbuild.Device) (*osbui func copyFSTreeOptions(inputName, inputPipeline string, pt *disk.PartitionTable, device *osbuild.Device) ( *osbuild.CopyStageOptions, *osbuild.CopyStageDevices, - *osbuild.CopyStageMounts, + osbuild.CopyStageMounts, ) { // assume loopback device for simplicity since it's the only one currently supported // panic if the conversion fails @@ -393,8 +394,8 @@ func copyFSTreeOptions(inputName, inputPipeline string, pt *disk.PartitionTable, } devices := make(map[string]osbuild.Device, len(pt.Partitions)) - mounts := make(map[string]osbuild.Mount, len(pt.Partitions)) - for _, p := range pt.Partitions { + mounts := make([]osbuild.Mount, len(pt.Partitions)) + for i, p := range pt.Partitions { if p.Filesystem == nil { // no filesystem for partition (e.g., BIOS boot) continue @@ -413,17 +414,17 @@ func copyFSTreeOptions(inputName, inputPipeline string, pt *disk.PartitionTable, var mount *osbuild.Mount switch p.Filesystem.Type { case "xfs": - mount = osbuild.NewXfsMount(name, p.Filesystem.Mountpoint) + mount = osbuild.NewXfsMount(name, name, p.Filesystem.Mountpoint) case "vfat": - mount = osbuild.NewFATMount(name, p.Filesystem.Mountpoint) + mount = osbuild.NewFATMount(name, name, p.Filesystem.Mountpoint) case "ext4": - mount = osbuild.NewExt4Mount(name, p.Filesystem.Mountpoint) + mount = osbuild.NewExt4Mount(name, name, p.Filesystem.Mountpoint) case "btrfs": - mount = osbuild.NewBtrfsMount(name, p.Filesystem.Mountpoint) + mount = osbuild.NewBtrfsMount(name, name, p.Filesystem.Mountpoint) default: panic("unknown fs type " + p.Type) } - mounts[name] = *mount + mounts[i] = *mount } stageMounts := osbuild.CopyStageMounts(mounts) @@ -438,7 +439,7 @@ func copyFSTreeOptions(inputName, inputPipeline string, pt *disk.PartitionTable, }, } - return &options, &stageDevices, &stageMounts + return &options, &stageDevices, stageMounts } func grub2InstStageOptions(filename string, pt *disk.PartitionTable, platform string) *osbuild.Grub2InstStageOptions { diff --git a/internal/osbuild2/btrfs_mount.go b/internal/osbuild2/btrfs_mount.go index 194c5b3a7..600afe19c 100644 --- a/internal/osbuild2/btrfs_mount.go +++ b/internal/osbuild2/btrfs_mount.go @@ -1,8 +1,9 @@ package osbuild2 -func NewBtrfsMount(source, target string) *Mount { +func NewBtrfsMount(name, source, target string) *Mount { return &Mount{ Type: "org.osbuild.btrfs", + Name: name, Source: source, Target: target, } diff --git a/internal/osbuild2/copy_stage.go b/internal/osbuild2/copy_stage.go index 2eec631e3..9fda80c6f 100644 --- a/internal/osbuild2/copy_stage.go +++ b/internal/osbuild2/copy_stage.go @@ -31,11 +31,11 @@ type CopyStageDevices map[string]Device func (CopyStageDevices) isStageDevices() {} -type CopyStageMounts map[string]Mount +type CopyStageMounts []Mount func (CopyStageMounts) isStageMounts() {} -func NewCopyStage(options *CopyStageOptions, inputs *CopyStageInputs, devices *CopyStageDevices, mounts *CopyStageMounts) *Stage { +func NewCopyStage(options *CopyStageOptions, inputs *CopyStageInputs, devices *CopyStageDevices, mounts CopyStageMounts) *Stage { return &Stage{ Type: "org.osbuild.copy", Options: options, diff --git a/internal/osbuild2/copy_stage_test.go b/internal/osbuild2/copy_stage_test.go index 06809d039..478fec1f8 100644 --- a/internal/osbuild2/copy_stage_test.go +++ b/internal/osbuild2/copy_stage_test.go @@ -15,7 +15,7 @@ func TestNewCopyStage(t *testing.T) { }, } devices := make(map[string]Device) - mounts := make(map[string]Mount) + var mounts []Mount devices["root"] = Device{ Type: "org.osbuild.loopback", Options: LoopbackDeviceOptions{ @@ -35,8 +35,8 @@ func TestNewCopyStage(t *testing.T) { Options: &CopyStageOptions{paths}, Inputs: &CopyStageInputs{"tree-input": treeInput}, Devices: ©StageDevices, - Mounts: ©StageMounts, + Mounts: copyStageMounts, } - actualStage := NewCopyStage(&CopyStageOptions{paths}, &CopyStageInputs{"tree-input": treeInput}, ©StageDevices, ©StageMounts) + actualStage := NewCopyStage(&CopyStageOptions{paths}, &CopyStageInputs{"tree-input": treeInput}, ©StageDevices, copyStageMounts) assert.Equal(t, expectedStage, actualStage) } diff --git a/internal/osbuild2/ext4_mount.go b/internal/osbuild2/ext4_mount.go index 817dc11d9..b835b639e 100644 --- a/internal/osbuild2/ext4_mount.go +++ b/internal/osbuild2/ext4_mount.go @@ -1,8 +1,9 @@ package osbuild2 -func NewExt4Mount(source, target string) *Mount { +func NewExt4Mount(name, source, target string) *Mount { return &Mount{ Type: "org.osbuild.ext4", + Name: name, Source: source, Target: target, } diff --git a/internal/osbuild2/fat_mount.go b/internal/osbuild2/fat_mount.go index c5b2e779b..2575a7037 100644 --- a/internal/osbuild2/fat_mount.go +++ b/internal/osbuild2/fat_mount.go @@ -1,8 +1,9 @@ package osbuild2 -func NewFATMount(source, target string) *Mount { +func NewFATMount(name, source, target string) *Mount { return &Mount{ Type: "org.osbuild.fat", + Name: name, Source: source, Target: target, } diff --git a/internal/osbuild2/mount.go b/internal/osbuild2/mount.go index 806753e68..054c063eb 100644 --- a/internal/osbuild2/mount.go +++ b/internal/osbuild2/mount.go @@ -5,6 +5,7 @@ type Mounts interface { } type Mount struct { + Name string `json:"name"` Type string `json:"type"` Source string `json:"source"` Target string `json:"target"` diff --git a/internal/osbuild2/mount_test.go b/internal/osbuild2/mount_test.go index 082cba490..2627e2b56 100644 --- a/internal/osbuild2/mount_test.go +++ b/internal/osbuild2/mount_test.go @@ -10,8 +10,9 @@ func TestNewMounts(t *testing.T) { assert := assert.New(t) { // btrfs - actual := NewBtrfsMount("/dev/sda1", "/mnt/btrfs") + actual := NewBtrfsMount("btrfs", "/dev/sda1", "/mnt/btrfs") expected := &Mount{ + Name: "btrfs", Type: "org.osbuild.btrfs", Source: "/dev/sda1", Target: "/mnt/btrfs", @@ -20,8 +21,9 @@ func TestNewMounts(t *testing.T) { } { // ext4 - actual := NewExt4Mount("/dev/sda2", "/mnt/ext4") + actual := NewExt4Mount("ext4", "/dev/sda2", "/mnt/ext4") expected := &Mount{ + Name: "ext4", Type: "org.osbuild.ext4", Source: "/dev/sda2", Target: "/mnt/ext4", @@ -30,8 +32,9 @@ func TestNewMounts(t *testing.T) { } { // fat - actual := NewFATMount("/dev/sda3", "/mnt/fat") + actual := NewFATMount("fat", "/dev/sda3", "/mnt/fat") expected := &Mount{ + Name: "fat", Type: "org.osbuild.fat", Source: "/dev/sda3", Target: "/mnt/fat", @@ -40,8 +43,9 @@ func TestNewMounts(t *testing.T) { } { // xfs - actual := NewXfsMount("/dev/sda4", "/mnt/xfs") + actual := NewXfsMount("xfs", "/dev/sda4", "/mnt/xfs") expected := &Mount{ + Name: "xfs", Type: "org.osbuild.xfs", Source: "/dev/sda4", Target: "/mnt/xfs", diff --git a/internal/osbuild2/xfs_mount.go b/internal/osbuild2/xfs_mount.go index 4be933d55..0f9e133f9 100644 --- a/internal/osbuild2/xfs_mount.go +++ b/internal/osbuild2/xfs_mount.go @@ -1,8 +1,9 @@ package osbuild2 -func NewXfsMount(source, target string) *Mount { +func NewXfsMount(name, source, target string) *Mount { return &Mount{ Type: "org.osbuild.xfs", + Name: name, Source: source, Target: target, }