osbuild/copy: support files input
Add support for files input in the copy stage. This will enable copying inline sources as a custom files in the image filesystem tree. Add a simple unit test covering the use of this stage input. Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
parent
b007b0ea12
commit
2e54557cd4
2 changed files with 30 additions and 0 deletions
|
|
@ -39,6 +39,10 @@ func NewCopyStageSimple(options *CopyStageOptions, inputs Inputs) *Stage {
|
|||
}
|
||||
}
|
||||
|
||||
type CopyStageFilesInputs map[string]*FilesInput
|
||||
|
||||
func (*CopyStageFilesInputs) isStageInputs() {}
|
||||
|
||||
// GenCopyFSTreeOptions creates the options, inputs, devices, and mounts properties
|
||||
// for an org.osbuild.copy stage for a given source tree using a partition
|
||||
// table description to define the mounts
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package osbuild
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
@ -43,3 +44,28 @@ func TestNewCopyStage(t *testing.T) {
|
|||
actualStage := NewCopyStage(&CopyStageOptions{paths}, NewPipelineTreeInputs("tree-input", "input-pipeline"), &stageDevices, &stageMounts)
|
||||
assert.Equal(t, expectedStage, actualStage)
|
||||
}
|
||||
|
||||
func TestNewCopyStageSimpleSourcesInputs(t *testing.T) {
|
||||
fileSum := "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
|
||||
|
||||
paths := []CopyStagePath{
|
||||
{
|
||||
From: fmt.Sprintf("input://inlinefile/sha256:%x", fileSum),
|
||||
To: "tree://etc/inlinefile",
|
||||
},
|
||||
}
|
||||
|
||||
filesInputs := CopyStageFilesInputs{
|
||||
"inlinefile": NewFilesInput(NewFilesInputSourceArrayRef([]FilesInputSourceArrayRefEntry{
|
||||
NewFilesInputSourceArrayRefEntry(fileSum, nil),
|
||||
})),
|
||||
}
|
||||
|
||||
expectedStage := &Stage{
|
||||
Type: "org.osbuild.copy",
|
||||
Options: &CopyStageOptions{paths},
|
||||
Inputs: &filesInputs,
|
||||
}
|
||||
actualStage := NewCopyStageSimple(&CopyStageOptions{paths}, &filesInputs)
|
||||
assert.Equal(t, expectedStage, actualStage)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue