-
Notifications
You must be signed in to change notification settings - Fork 44
/
vmdk.go
64 lines (53 loc) · 1.64 KB
/
vmdk.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package manifest
import (
"github.com/osbuild/images/pkg/artifact"
"github.com/osbuild/images/pkg/osbuild"
)
// A VMDK turns a raw image file or a raw ostree image file into vmdk image.
type VMDK struct {
Base
filename string
imgPipeline Pipeline
}
func (p VMDK) Filename() string {
return p.filename
}
func (p *VMDK) SetFilename(filename string) {
p.filename = filename
}
// NewVMDK creates a new VMDK pipeline. imgPipeline is the pipeline producing the
// raw image. imgOstreePipeline is the pipeline producing the raw ostree image.
// Either imgPipeline or imgOStreePipeline are required, but not both at the same time.
// Filename is the name of the produced image.
func NewVMDK(buildPipeline Build, imgPipeline FilePipeline) *VMDK {
p := &VMDK{
Base: NewBase("vmdk", buildPipeline),
imgPipeline: imgPipeline,
filename: "image.vmdk",
}
// See similar logic in qcow2 to run on the host
if buildPipeline != nil {
buildPipeline.addDependent(p)
} else {
imgPipeline.Manifest().addPipeline(p)
}
return p
}
func (p *VMDK) serialize() osbuild.Pipeline {
pipeline := p.Base.serialize()
pipeline.AddStage(osbuild.NewQEMUStage(
osbuild.NewQEMUStageOptions(p.Filename(), osbuild.QEMUFormatVMDK, osbuild.VMDKOptions{
Subformat: osbuild.VMDKSubformatStreamOptimized,
}),
osbuild.NewQemuStagePipelineFilesInputs(p.imgPipeline.Name(), p.imgPipeline.Export().Filename()),
))
return pipeline
}
func (p *VMDK) getBuildPackages(Distro) []string {
return []string{"qemu-img"}
}
func (p *VMDK) Export() *artifact.Artifact {
p.Base.export = true
mimeType := "application/x-vmdk"
return artifact.New(p.Name(), p.Filename(), &mimeType)
}