Skip to content

Commit

Permalink
osbuild: add Transform to TarStageOptions
Browse files Browse the repository at this point in the history
This commit adds the new `transform` option to the tar stage. This
allows chaning filenames while runnig tar and will be used by the
GCE pipeline for bootc-disk.

See also osbuild/osbuild#1886
  • Loading branch information
mvo5 committed Sep 17, 2024
1 parent 8a59516 commit bdf2d4c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/osbuild/tar_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ type TarStageOptions struct {

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

// Pass --transform=...
Transform string `json:"transform,omitempty"`
}

func (TarStageOptions) isStageOptions() {}
Expand Down
14 changes: 14 additions & 0 deletions pkg/osbuild/tar_stage_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package osbuild

import (
"encoding/json"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -77,3 +78,16 @@ func TestTarStageOptionsValidate(t *testing.T) {
})
}
}

func TestTarStageOptionsJSON(t *testing.T) {
stageOptions := &TarStageOptions{
Filename: "archive.tar.xz",
Transform: "s/foo/bar/",
}
b, err := json.MarshalIndent(stageOptions, "", " ")
assert.NoError(t, err)
assert.Equal(t, string(b), `{
"filename": "archive.tar.xz",
"transform": "s/foo/bar/"
}`)
}

0 comments on commit bdf2d4c

Please sign in to comment.