Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image: add vhd/vpc support to BootcDiskImage #909

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/image/bootc_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ func (img *BootcDiskImage) InstantiateManifestFromContainers(m *manifest.Manifes
vmdkPipeline := manifest.NewVMDK(hostPipeline, rawImage)
vmdkPipeline.SetFilename(fmt.Sprintf("%s.vmdk", fileBasename))

vhdPipeline := manifest.NewVPC(hostPipeline, rawImage)
vhdPipeline.SetFilename(fmt.Sprintf("%s.vhd", fileBasename))

ovfPipeline := manifest.NewOVF(hostPipeline, vmdkPipeline)
tarPipeline := manifest.NewTar(hostPipeline, ovfPipeline, "archive")
tarPipeline.Format = osbuild.TarArchiveFormatUstar
Expand All @@ -84,6 +87,7 @@ func (img *BootcDiskImage) InstantiateManifestFromContainers(m *manifest.Manifes
fmt.Sprintf("%s.ovf", fileBasename),
fmt.Sprintf("%s.mf", fileBasename),
fmt.Sprintf("%s.vmdk", fileBasename),
fmt.Sprintf("%s.vhd", fileBasename),
}
return nil
}
13 changes: 13 additions & 0 deletions pkg/image/bootc_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ func TestBootcDiskImageInstantiateNoBuildpipelineForQcow2(t *testing.T) {
assert.Equal(t, qcowPipeline["build"], nil)
}

func TestBootcDiskImageInstantiateNoBuildpipelineForVpc(t *testing.T) {
osbuildManifest := makeBootcDiskImageOsbuildManifest(t, nil)

vpcPipeline := findPipelineFromOsbuildManifest(t, osbuildManifest, "vpc")
require.NotNil(t, vpcPipeline)
// no build pipeline for vpc
assert.Equal(t, vpcPipeline["build"], nil)
}

func TestBootcDiskImageInstantiateVmdk(t *testing.T) {
opts := &bootcDiskImageTestOpts{ImageFormat: platform.FORMAT_VMDK}
osbuildManifest := makeBootcDiskImageOsbuildManifest(t, opts)
Expand Down Expand Up @@ -185,6 +194,10 @@ func TestBootcDiskImageExportPipelines(t *testing.T) {
vmdkPipeline := findPipelineFromOsbuildManifest(t, osbuildManifest, "vmdk")
require.NotNil(vmdkPipeline)

// vpc pipeline for the vhd
vpcPipeline := findPipelineFromOsbuildManifest(t, osbuildManifest, "vpc")
require.NotNil(vpcPipeline)

// tar pipeline for ova
tarPipeline := findPipelineFromOsbuildManifest(t, osbuildManifest, "archive")
require.NotNil(tarPipeline)
Expand Down
13 changes: 9 additions & 4 deletions pkg/manifest/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"github.com/osbuild/images/pkg/osbuild"
)

// A VPC turns a raw image file into qemu-based image format, such as qcow2.
// A VPC turns a raw image file into qemu-based image format, such as vhd.
type VPC struct {
Base
filename string

ForceSize *bool

imgPipeline *RawImage
imgPipeline FilePipeline
}

func (p VPC) Filename() string {
Expand All @@ -26,13 +26,18 @@ func (p *VPC) SetFilename(filename string) {
// NewVPC 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 NewVPC(buildPipeline Build, imgPipeline *RawImage) *VPC {
func NewVPC(buildPipeline Build, imgPipeline FilePipeline) *VPC {
p := &VPC{
Base: NewBase("vpc", buildPipeline),
imgPipeline: imgPipeline,
filename: "image.vhd",
}
buildPipeline.addDependent(p)
// vpc can run outside the build pipeline for e.g. "bib"
if buildPipeline != nil {
buildPipeline.addDependent(p)
} else {
imgPipeline.Manifest().addPipeline(p)
}
return p
}

Expand Down
Loading