osbuild: rework QEMU stage inputs
Rework the stage to not reimplement `FilesInput` as `QEMUStageInput`, but instead use the one common `FilesInput` implementation and its supported references. Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
parent
3f90a32661
commit
645956d203
2 changed files with 4 additions and 38 deletions
|
|
@ -163,29 +163,11 @@ func (o VHDXOptions) formatType() QEMUFormat {
|
|||
}
|
||||
|
||||
type QEMUStageInputs struct {
|
||||
Image *QEMUStageInput `json:"image"`
|
||||
Image *FilesInput `json:"image"`
|
||||
}
|
||||
|
||||
func (QEMUStageInputs) isStageInputs() {}
|
||||
|
||||
type QEMUStageInput struct {
|
||||
inputCommon
|
||||
References QEMUStageReferences `json:"references"`
|
||||
}
|
||||
|
||||
func (QEMUStageInput) isStageInput() {}
|
||||
|
||||
type QEMUStageReferences map[string]QEMUFile
|
||||
|
||||
func (QEMUStageReferences) isReferences() {}
|
||||
|
||||
type QEMUFile struct {
|
||||
Metadata FileMetadata `json:"metadata,omitempty"`
|
||||
File string `json:"file,omitempty"`
|
||||
}
|
||||
|
||||
type FileMetadata map[string]interface{}
|
||||
|
||||
// NewQEMUStage creates a new QEMU Stage object.
|
||||
func NewQEMUStage(options *QEMUStageOptions, inputs *QEMUStageInputs) *Stage {
|
||||
return &Stage{
|
||||
|
|
@ -271,16 +253,7 @@ func (options QEMUStageOptions) MarshalJSON() ([]byte, error) {
|
|||
return json.Marshal(qemuStageOptions(options))
|
||||
}
|
||||
|
||||
func NewQemuStagePipelineFilesInputs(stage, file string) *QEMUStageInputs {
|
||||
stageKey := "name:" + stage
|
||||
ref := map[string]QEMUFile{
|
||||
stageKey: {
|
||||
File: file,
|
||||
},
|
||||
}
|
||||
input := new(QEMUStageInput)
|
||||
input.Type = "org.osbuild.files"
|
||||
input.Origin = "org.osbuild.pipeline"
|
||||
input.References = ref
|
||||
func NewQemuStagePipelineFilesInputs(pipeline, file string) *QEMUStageInputs {
|
||||
input := NewFilesInput(NewFilesInputPipelineObjectRef(pipeline, file, nil))
|
||||
return &QEMUStageInputs{Image: input}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,14 +30,7 @@ func TestNewQemuStage(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
input := new(QEMUStageInput)
|
||||
input.Type = "org.osbuild.files"
|
||||
input.Origin = "org.osbuild.pipeline"
|
||||
input.References = map[string]QEMUFile{
|
||||
"name:stage": {
|
||||
File: "img.raw",
|
||||
},
|
||||
}
|
||||
input := NewFilesInput(NewFilesInputPipelineObjectRef("stage", "img.raw", nil))
|
||||
inputs := QEMUStageInputs{Image: input}
|
||||
|
||||
for _, format := range formatOptionsList {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue