osbuild2: remove stage-specific mount types
Mounts unlike stage options, shouldn't be stage specific. We have filesystem specific mount types, differentiated by their type string. Mounts can define their own additional options if necessary. The top level Mounts type is simply an alias to a Mount array. Signed-off-by: Achilleas Koutsou <achilleas@koutsou.net>
This commit is contained in:
parent
613ad0b862
commit
c74d13daf8
7 changed files with 17 additions and 23 deletions
|
|
@ -1006,7 +1006,7 @@ func bootloaderConfigStage(t *imageType, partitionTable disk.PartitionTable, ker
|
|||
return osbuild.NewGRUB2Stage(grub2StageOptions(partitionTable.RootPartition(), partitionTable.BootPartition(), kernelOptions, kernel, kernelVer, uefi, legacy))
|
||||
}
|
||||
|
||||
func bootloaderInstStage(filename string, pt *disk.PartitionTable, arch *architecture, kernelVer string, devices *osbuild.CopyStageDevices, mounts *osbuild.CopyStageMounts, disk *osbuild.Device) *osbuild.Stage {
|
||||
func bootloaderInstStage(filename string, pt *disk.PartitionTable, arch *architecture, kernelVer string, devices *osbuild.CopyStageDevices, mounts *osbuild.Mounts, disk *osbuild.Device) *osbuild.Stage {
|
||||
platform := arch.legacy
|
||||
if platform != "" {
|
||||
return osbuild.NewGrub2InstStage(grub2InstStageOptions(filename, pt, platform))
|
||||
|
|
|
|||
|
|
@ -382,7 +382,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.Mounts,
|
||||
) {
|
||||
// assume loopback device for simplicity since it's the only one currently supported
|
||||
// panic if the conversion fails
|
||||
|
|
@ -433,7 +433,7 @@ func copyFSTreeOptions(inputName, inputPipeline string, pt *disk.PartitionTable,
|
|||
return mounts[i].Target < mounts[j].Target
|
||||
})
|
||||
|
||||
stageMounts := osbuild.CopyStageMounts(mounts)
|
||||
stageMounts := osbuild.Mounts(mounts)
|
||||
stageDevices := osbuild.CopyStageDevices(devices)
|
||||
|
||||
options := osbuild.CopyStageOptions{
|
||||
|
|
|
|||
|
|
@ -31,16 +31,12 @@ type CopyStageDevices map[string]Device
|
|||
|
||||
func (CopyStageDevices) isStageDevices() {}
|
||||
|
||||
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 *Mounts) *Stage {
|
||||
return &Stage{
|
||||
Type: "org.osbuild.copy",
|
||||
Options: options,
|
||||
Inputs: inputs,
|
||||
Devices: devices,
|
||||
Mounts: mounts,
|
||||
Mounts: *mounts,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ func TestNewCopyStage(t *testing.T) {
|
|||
To: "mount://root/",
|
||||
},
|
||||
}
|
||||
|
||||
devices := make(map[string]Device)
|
||||
var mounts []Mount
|
||||
devices["root"] = Device{
|
||||
Type: "org.osbuild.loopback",
|
||||
Options: LoopbackDeviceOptions{
|
||||
|
|
@ -24,19 +24,24 @@ func TestNewCopyStage(t *testing.T) {
|
|||
Size: 1073741824,
|
||||
},
|
||||
}
|
||||
|
||||
mounts := []Mount{
|
||||
*NewBtrfsMount("root", "root", "/"),
|
||||
}
|
||||
|
||||
treeInput := CopyStageInput{}
|
||||
treeInput.Type = "org.osbuild.tree"
|
||||
treeInput.Origin = "org.osbuild.pipeline"
|
||||
treeInput.References = []string{"name:input-pipeline"}
|
||||
copyStageMounts := CopyStageMounts(mounts)
|
||||
copyStageDevices := CopyStageDevices(devices)
|
||||
expectedStage := &Stage{
|
||||
Type: "org.osbuild.copy",
|
||||
Options: &CopyStageOptions{paths},
|
||||
Inputs: &CopyStageInputs{"tree-input": treeInput},
|
||||
Devices: ©StageDevices,
|
||||
Mounts: ©StageMounts,
|
||||
Mounts: mounts,
|
||||
}
|
||||
actualStage := NewCopyStage(&CopyStageOptions{paths}, &CopyStageInputs{"tree-input": treeInput}, ©StageDevices, ©StageMounts)
|
||||
stageMounts := Mounts(mounts)
|
||||
actualStage := NewCopyStage(&CopyStageOptions{paths}, &CopyStageInputs{"tree-input": treeInput}, ©StageDevices, &stageMounts)
|
||||
assert.Equal(t, expectedStage, actualStage)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
package osbuild2
|
||||
|
||||
type Mounts interface {
|
||||
isStageMounts()
|
||||
}
|
||||
type Mounts []Mount
|
||||
|
||||
type Mount struct {
|
||||
Name string `json:"name"`
|
||||
|
|
|
|||
|
|
@ -116,7 +116,6 @@ func (stage *Stage) UnmarshalJSON(data []byte) error {
|
|||
options = new(CopyStageOptions)
|
||||
inputs = new(CopyStageInputs)
|
||||
devices = new(CopyStageDevices)
|
||||
mounts = new(CopyStageMounts)
|
||||
case "org.osbuild.mkfs.btrfs":
|
||||
options = new(MkfsBtrfsStageOptions)
|
||||
devices = new(MkfsBtrfsStageDevices)
|
||||
|
|
|
|||
|
|
@ -17,16 +17,12 @@ type ZiplInstStageDevices map[string]Device
|
|||
|
||||
func (ZiplInstStageDevices) isStageDevices() {}
|
||||
|
||||
type ZiplInstStageMounts []Mount
|
||||
|
||||
func (ZiplInstStageMounts) isStageMounts() {}
|
||||
|
||||
// Return a new zipl.inst stage. A device needs to be specified as 'disk' and root mountpoint must be provided
|
||||
func NewZiplInstStage(options *ZiplInstStageOptions, devices *CopyStageDevices, mounts *CopyStageMounts) *Stage {
|
||||
func NewZiplInstStage(options *ZiplInstStageOptions, devices *CopyStageDevices, mounts *Mounts) *Stage {
|
||||
return &Stage{
|
||||
Type: "org.osbuild.zipl.inst",
|
||||
Options: options,
|
||||
Devices: devices,
|
||||
Mounts: mounts,
|
||||
Mounts: *mounts,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue