Skip to content

Commit

Permalink
image: add new gce pipeline to BootcDiskImage
Browse files Browse the repository at this point in the history
There is a request that we provide a new image type that can
be imported directly into GCE. This requires a `tar.gz` with
a `disk.raw` inside and specific tar options.

This commit adds the needed pipeline to generate this.

Note that this will require a way to rename files during
the tar build as we do not want to hardcode the raw image
filename.
  • Loading branch information
mvo5 committed Sep 17, 2024
1 parent b9b0214 commit faccc4d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/image/bootc_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package image
import (
"fmt"
"math/rand"
"regexp"

"github.com/osbuild/images/internal/common"
"github.com/osbuild/images/pkg/container"
"github.com/osbuild/images/pkg/customizations/users"
"github.com/osbuild/images/pkg/disk"
Expand Down Expand Up @@ -89,5 +91,17 @@ func (img *BootcDiskImage) InstantiateManifestFromContainers(m *manifest.Manifes
fmt.Sprintf("%s.vmdk", fileBasename),
fmt.Sprintf("%s.vhd", fileBasename),
}

// XXX: copied from https://github.com/osbuild/images/blob/v0.85.0/pkg/image/disk.go#L102
gcePipeline := manifest.NewTar(buildPipeline, rawImage, "gce")
gcePipeline.Format = osbuild.TarArchiveFormatOldgnu
gcePipeline.RootNode = osbuild.TarRootNodeOmit
// these are required to successfully import the image to GCP
gcePipeline.ACLs = common.ToPtr(false)
gcePipeline.SELinux = common.ToPtr(false)
gcePipeline.Xattrs = common.ToPtr(false)
gcePipeline.Transform = fmt.Sprintf(`s/%s/disk.raw`, regexp.QuoteMeta(rawImage.Filename()))
gcePipeline.SetFilename("image.tgz")

return nil
}
4 changes: 4 additions & 0 deletions pkg/image/bootc_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ func TestBootcDiskImageExportPipelines(t *testing.T) {
// tar pipeline for ova
tarPipeline := findPipelineFromOsbuildManifest(t, osbuildManifest, "archive")
require.NotNil(tarPipeline)

// raw-tgz pipeline
gcePipeline := findPipelineFromOsbuildManifest(t, osbuildManifest, "gce")
require.NotNil(gcePipeline)
}

func TestBootcDiskImageInstantiateUsers(t *testing.T) {
Expand Down

0 comments on commit faccc4d

Please sign in to comment.