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

disk(ova): correct archive order #426

Merged
merged 3 commits into from
Feb 8, 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
10 changes: 9 additions & 1 deletion pkg/image/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package image
import (
"fmt"
"math/rand"
"path/filepath"
"strings"

"github.com/osbuild/images/internal/common"
"github.com/osbuild/images/internal/environment"
Expand Down Expand Up @@ -87,8 +89,14 @@ func (img *DiskImage) InstantiateManifest(m *manifest.Manifest,
ovfPipeline := manifest.NewOVF(buildPipeline, vmdkPipeline)
tarPipeline := manifest.NewTar(buildPipeline, ovfPipeline, "archive")
tarPipeline.Format = osbuild.TarArchiveFormatUstar
tarPipeline.RootNode = osbuild.TarRootNodeOmit
tarPipeline.SetFilename(img.Filename)
extLess := strings.TrimSuffix(img.Filename, filepath.Ext(img.Filename))
// The .ovf descriptor needs to be the first file in the archive
tarPipeline.Paths = []string{
fmt.Sprintf("%s.ovf", extLess),
fmt.Sprintf("%s.mf", extLess),
fmt.Sprintf("%s.vmdk", extLess),
}
imagePipeline = tarPipeline
case platform.FORMAT_GCE:
// NOTE(akoutsou): temporary workaround; filename required for GCP
Expand Down
2 changes: 2 additions & 0 deletions pkg/manifest/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Tar struct {

Format osbuild.TarArchiveFormat
RootNode osbuild.TarRootNode
Paths []string
ACLs *bool
SELinux *bool
Xattrs *bool
Expand Down Expand Up @@ -50,6 +51,7 @@ func (p *Tar) serialize() osbuild.Pipeline {
SELinux: p.SELinux,
Xattrs: p.Xattrs,
RootNode: p.RootNode,
Paths: p.Paths,
}
tarStage := osbuild.NewTarStage(tarOptions, p.inputPipeline.Name())
pipeline.AddStage(tarStage)
Expand Down
7 changes: 7 additions & 0 deletions pkg/osbuild/tar_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ type TarStageOptions struct {

// How to handle the root node: include or omit
RootNode TarRootNode `json:"root-node,omitempty"`

// List of paths to include, instead of the whole tree
Paths []string `json:"paths,omitempty"`
}

func (TarStageOptions) isStageOptions() {}
Expand Down Expand Up @@ -81,6 +84,10 @@ func (o TarStageOptions) validate() error {
}
}

if len(o.Paths) > 0 && o.RootNode != "" {
return fmt.Errorf("'paths' cannot be combined with 'root-node'")
}

return nil
}

Expand Down
Loading