osbuild2: add QEMU format options for vdi and vhdx

Although these format types are not used by any of the image definitions
at this moment, add them since they are supported by the osbuild stage.
This commit is contained in:
Tomas Hozza 2022-04-06 10:19:09 +02:00 committed by Tomáš Hozza
parent 8697713ce8
commit f5d70d6b58
2 changed files with 34 additions and 0 deletions

View file

@ -52,6 +52,20 @@ func (o QCOW2Options) validate() error {
return nil
}
type VDIOptions struct {
// The type of the format must be 'vdi'
Type QEMUFormat `json:"type"`
}
func (VDIOptions) isQEMUFormatOptions() {}
func (o VDIOptions) validate() error {
if o.Type != QEMUFormatVDI {
return fmt.Errorf("invalid format type %q for %q options", o.Type, QEMUFormatVDI)
}
return nil
}
type VPCOptions struct {
// The type of the format must be 'vpc'
Type QEMUFormat `json:"type"`
@ -80,6 +94,20 @@ func (o VMDKOptions) validate() error {
return nil
}
type VHDXOptions struct {
// The type of the format must be 'vhdx'
Type QEMUFormat `json:"type"`
}
func (VHDXOptions) isQEMUFormatOptions() {}
func (o VHDXOptions) validate() error {
if o.Type != QEMUFormatVHDX {
return fmt.Errorf("invalid format type %q for %q options", o.Type, QEMUFormatVHDX)
}
return nil
}
type QEMUStageInputs struct {
Image *QEMUStageInput `json:"image"`
}

View file

@ -13,12 +13,18 @@ func TestNewQemuStage(t *testing.T) {
Type: QEMUFormatQCOW2,
Compat: "0.10",
},
VDIOptions{
Type: QEMUFormatVDI,
},
VPCOptions{
Type: QEMUFormatVPC,
},
VMDKOptions{
Type: QEMUFormatVMDK,
},
VHDXOptions{
Type: QEMUFormatVHDX,
},
}
input := new(QEMUStageInput)