debian-forge-composer/internal/pipeline/vpc.go
Tom Gundersen 4556312d22 pipeline: split qcow2 into format specific pipelines
Stages are procedural and named after the tool they wrap, but pipelines are declarative and should
be named after the kind of artefact they produce.

This splits the qemu (the tool) pipeline into qcow2, vmdk, and vpc (the formats) pipelines. In theory
we may have wanted to implemented through some shared helpers, but for now it seems trivial
enough that it is not worth it.
2022-06-27 19:11:26 +01:00

35 lines
1,021 B
Go

package pipeline
import (
"github.com/osbuild/osbuild-composer/internal/osbuild2"
)
// A VPCPipeline turns a raw image file into qemu-based image format, such as qcow2.
type VPCPipeline struct {
Pipeline
imgPipeline *LiveImgPipeline
filename string
}
// NewVPCPipeline createsa new Qemu pipeline. imgPipeline is the pipeline producing the
// raw image. The pipeline name is the name of the new pipeline. Filename is the name
// of the produced image.
func NewVPCPipeline(buildPipeline *BuildPipeline, imgPipeline *LiveImgPipeline, filename string) VPCPipeline {
return VPCPipeline{
Pipeline: New("vpc", buildPipeline, nil),
imgPipeline: imgPipeline,
filename: filename,
}
}
func (p VPCPipeline) Serialize() osbuild2.Pipeline {
pipeline := p.Pipeline.Serialize()
pipeline.AddStage(osbuild2.NewQEMUStage(
osbuild2.NewQEMUStageOptions(p.filename, osbuild2.QEMUFormatVPC, nil),
osbuild2.NewQemuStagePipelineFilesInputs(p.imgPipeline.Name(), p.imgPipeline.Filename()),
))
return pipeline
}