Skip to content

Commit

Permalink
manifest: add transform to manifest.Tar`
Browse files Browse the repository at this point in the history
This commit adds the new osbuild.TarStageOptions option `transform`
to the `manifest.Tar` object so that it can be used by the
`image.BootcDiskImage` later.
  • Loading branch information
mvo5 committed Sep 17, 2024
1 parent bdf2d4c commit b9b0214
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 13 deletions.
8 changes: 8 additions & 0 deletions pkg/manifest/export_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
package manifest

import (
"github.com/osbuild/images/pkg/osbuild"
)

var FindStage = findStage

func (p *Tar) Serialize() osbuild.Pipeline {
return p.serialize()
}
28 changes: 15 additions & 13 deletions pkg/manifest/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ type Tar struct {
Base
filename string

Format osbuild.TarArchiveFormat
RootNode osbuild.TarRootNode
Paths []string
ACLs *bool
SELinux *bool
Xattrs *bool
Format osbuild.TarArchiveFormat
RootNode osbuild.TarRootNode
Paths []string
ACLs *bool
SELinux *bool
Xattrs *bool
Transform string

inputPipeline Pipeline
}
Expand Down Expand Up @@ -50,13 +51,14 @@ func (p *Tar) serialize() osbuild.Pipeline {
pipeline := p.Base.serialize()

tarOptions := &osbuild.TarStageOptions{
Filename: p.Filename(),
Format: p.Format,
ACLs: p.ACLs,
SELinux: p.SELinux,
Xattrs: p.Xattrs,
RootNode: p.RootNode,
Paths: p.Paths,
Filename: p.Filename(),
Format: p.Format,
ACLs: p.ACLs,
SELinux: p.SELinux,
Xattrs: p.Xattrs,
RootNode: p.RootNode,
Paths: p.Paths,
Transform: p.Transform,
}
tarStage := osbuild.NewTarStage(tarOptions, p.inputPipeline.Name())
pipeline.AddStage(tarStage)
Expand Down
35 changes: 35 additions & 0 deletions pkg/manifest/tar_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package manifest_test

import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/osbuild/images/pkg/manifest"
"github.com/osbuild/images/pkg/osbuild"
"github.com/osbuild/images/pkg/runner"
)

func TestTarSerialize(t *testing.T) {
mani := manifest.New()
runner := &runner.Linux{}
build := manifest.NewBuild(&mani, runner, nil, nil)

// setup
rawImage := manifest.NewRawImage(build, nil)
tarPipeline := manifest.NewTar(build, rawImage, "tar-pipeline")
tarPipeline.SetFilename("filename.tar")
tarPipeline.Transform = "s/foo/bar"

// run
osbuildPipeline := tarPipeline.Serialize()

// assert
assert.Equal(t, "tar-pipeline", osbuildPipeline.Name)
assert.Equal(t, 1, len(osbuildPipeline.Stages))
tarStage := osbuildPipeline.Stages[0]
assert.Equal(t, &osbuild.TarStageOptions{
Filename: "filename.tar",
Transform: "s/foo/bar",
}, tarStage.Options.(*osbuild.TarStageOptions))
}

0 comments on commit b9b0214

Please sign in to comment.