osbuild: simplify and unify tree stage inputs
- Remove stage-specific input types when they are org.osbuild.tree input types. - Use PipelineTreeInputs when stage requires a single tree input reference with an arbitrary key. - For Stages that require a specific key with a tree input, make the key part of the NewXStage() function and only allow specifying the name of the pipeline from which to copy the tree as part of the function arguments.
This commit is contained in:
parent
ca0175c82b
commit
3d772b6846
19 changed files with 72 additions and 222 deletions
|
|
@ -315,7 +315,7 @@ func liveImagePipeline(inputPipelineName string, outputFilename string, pt *disk
|
|||
|
||||
inputName := "root-tree"
|
||||
copyOptions, copyDevices, copyMounts := osbuild.GenCopyFSTreeOptions(inputName, inputPipelineName, outputFilename, pt)
|
||||
copyInputs := osbuild.NewCopyStagePipelineTreeInputs(inputName, inputPipelineName)
|
||||
copyInputs := osbuild.NewPipelineTreeInputs(inputName, inputPipelineName)
|
||||
p.AddStage(osbuild.NewCopyStage(copyOptions, copyInputs, copyDevices, copyMounts))
|
||||
|
||||
for _, stage := range osbuild.GenImageFinishStages(pt, outputFilename) {
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ func imageInstallerPipelines(t *imageType, customizations *blueprint.Customizati
|
|||
kernelVer := fmt.Sprintf("%s-%s.%s", kernelPkg.Version, kernelPkg.Release, kernelPkg.Arch)
|
||||
|
||||
tarPath := "/liveimg.tar"
|
||||
tarPayloadStages := []*osbuild.Stage{osbuild.NewTarStage(&osbuild.TarStageOptions{Filename: tarPath}, osbuild.NewTarStagePipelineTreeInputs(treePipeline.Name))}
|
||||
tarPayloadStages := []*osbuild.Stage{osbuild.NewTarStage(&osbuild.TarStageOptions{Filename: tarPath}, treePipeline.Name)}
|
||||
kickstartOptions, err := osbuild.NewKickstartStageOptions(kspath, makeISORootPath(tarPath), customizations.GetUsers(), customizations.GetGroups(), "", "", "rhel")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -683,18 +683,15 @@ func ostreeCommitPipeline(options distro.ImageOptions, osVersion string) *osbuil
|
|||
p.Build = "name:build"
|
||||
p.AddStage(osbuild.NewOSTreeInitStage(&osbuild.OSTreeInitStageOptions{Path: "/repo"}))
|
||||
|
||||
commitStageInput := new(osbuild.OSTreeCommitStageInput)
|
||||
commitStageInput.Type = "org.osbuild.tree"
|
||||
commitStageInput.Origin = "org.osbuild.pipeline"
|
||||
commitStageInput.References = osbuild.OSTreeCommitStageReferences{"name:ostree-tree"}
|
||||
|
||||
p.AddStage(osbuild.NewOSTreeCommitStage(
|
||||
&osbuild.OSTreeCommitStageOptions{
|
||||
Ref: options.OSTree.Ref,
|
||||
OSVersion: osVersion,
|
||||
Parent: options.OSTree.Parent,
|
||||
},
|
||||
&osbuild.OSTreeCommitStageInputs{Tree: commitStageInput}),
|
||||
p.AddStage(
|
||||
osbuild.NewOSTreeCommitStage(
|
||||
&osbuild.OSTreeCommitStageOptions{
|
||||
Ref: options.OSTree.Ref,
|
||||
OSVersion: osVersion,
|
||||
Parent: options.OSTree.Parent,
|
||||
},
|
||||
"ostree-tree",
|
||||
),
|
||||
)
|
||||
return p
|
||||
}
|
||||
|
|
@ -740,10 +737,7 @@ func containerPipeline(t *imageType, nginxConfigPath, listenPort string) *osbuil
|
|||
ExposedPorts: []string{listenPort},
|
||||
},
|
||||
}
|
||||
baseInput := new(osbuild.OCIArchiveStageInput)
|
||||
baseInput.Type = "org.osbuild.tree"
|
||||
baseInput.Origin = "org.osbuild.pipeline"
|
||||
baseInput.References = []string{"name:container-tree"}
|
||||
baseInput := osbuild.NewTreeInput("name:container-tree")
|
||||
inputs := &osbuild.OCIArchiveStageInputs{Base: baseInput}
|
||||
p.AddStage(osbuild.NewOCIArchiveStage(options, inputs))
|
||||
return p
|
||||
|
|
@ -847,12 +841,12 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string, rn
|
|||
}
|
||||
|
||||
inputName := "root-tree"
|
||||
copyInputs := osbuild.NewCopyStagePipelineTreeInputs(inputName, "efiboot-tree")
|
||||
copyInputs := osbuild.NewPipelineTreeInputs(inputName, "efiboot-tree")
|
||||
copyOptions, copyDevices, copyMounts := osbuild.GenCopyFSTreeOptions(inputName, "efiboot-tree", filename, &pt)
|
||||
p.AddStage(osbuild.NewCopyStage(copyOptions, copyInputs, copyDevices, copyMounts))
|
||||
|
||||
inputName = "coi"
|
||||
copyInputs = osbuild.NewCopyStagePipelineTreeInputs(inputName, "coi-tree")
|
||||
copyInputs = osbuild.NewPipelineTreeInputs(inputName, "coi-tree")
|
||||
p.AddStage(osbuild.NewCopyStageSimple(
|
||||
&osbuild.CopyStageOptions{
|
||||
Paths: []osbuild.CopyStagePath{
|
||||
|
|
@ -870,7 +864,7 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string, rn
|
|||
))
|
||||
|
||||
inputName = "efi-tree"
|
||||
copyInputs = osbuild.NewCopyStagePipelineTreeInputs(inputName, "efiboot-tree")
|
||||
copyInputs = osbuild.NewPipelineTreeInputs(inputName, "efiboot-tree")
|
||||
p.AddStage(osbuild.NewCopyStageSimple(
|
||||
&osbuild.CopyStageOptions{
|
||||
Paths: []osbuild.CopyStagePath{
|
||||
|
|
@ -1087,7 +1081,7 @@ func bootISOPipeline(filename, isolabel, arch string, isolinux bool) *osbuild.Pi
|
|||
p.Name = "bootiso"
|
||||
p.Build = "name:build"
|
||||
|
||||
p.AddStage(osbuild.NewXorrisofsStage(xorrisofsStageOptions(filename, isolabel, arch, isolinux), osbuild.NewXorrisofsStagePipelineTreeInputs("bootiso-tree")))
|
||||
p.AddStage(osbuild.NewXorrisofsStage(xorrisofsStageOptions(filename, isolabel, arch, isolinux), "bootiso-tree"))
|
||||
p.AddStage(osbuild.NewImplantisomd5Stage(&osbuild.Implantisomd5StageOptions{Filename: filename}))
|
||||
|
||||
return p
|
||||
|
|
@ -1104,7 +1098,7 @@ func liveImagePipeline(inputPipelineName string, outputFilename string, pt *disk
|
|||
|
||||
inputName := "root-tree"
|
||||
copyOptions, copyDevices, copyMounts := osbuild.GenCopyFSTreeOptions(inputName, inputPipelineName, outputFilename, pt)
|
||||
copyInputs := osbuild.NewCopyStagePipelineTreeInputs(inputName, inputPipelineName)
|
||||
copyInputs := osbuild.NewPipelineTreeInputs(inputName, inputPipelineName)
|
||||
p.AddStage(osbuild.NewCopyStage(copyOptions, copyInputs, copyDevices, copyMounts))
|
||||
|
||||
for _, stage := range osbuild.GenImageFinishStages(pt, outputFilename) {
|
||||
|
|
@ -1134,7 +1128,7 @@ func tarArchivePipeline(name, inputPipelineName string, tarOptions *osbuild.TarS
|
|||
p := new(osbuild.Pipeline)
|
||||
p.Name = name
|
||||
p.Build = "name:build"
|
||||
p.AddStage(osbuild.NewTarStage(tarOptions, osbuild.NewTarStagePipelineTreeInputs(inputPipelineName)))
|
||||
p.AddStage(osbuild.NewTarStage(tarOptions, inputPipelineName))
|
||||
return p
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ func imageInstallerPipelines(t *imageType, customizations *blueprint.Customizati
|
|||
kernelVer := fmt.Sprintf("%s-%s.%s", kernelPkg.Version, kernelPkg.Release, kernelPkg.Arch)
|
||||
|
||||
tarPath := "/liveimg.tar"
|
||||
tarPayloadStages := []*osbuild.Stage{osbuild.NewTarStage(&osbuild.TarStageOptions{Filename: tarPath}, osbuild.NewTarStagePipelineTreeInputs(treePipeline.Name))}
|
||||
tarPayloadStages := []*osbuild.Stage{osbuild.NewTarStage(&osbuild.TarStageOptions{Filename: tarPath}, treePipeline.Name)}
|
||||
kickstartOptions, err := osbuild.NewKickstartStageOptions(kspath, makeISORootPath(tarPath), customizations.GetUsers(), customizations.GetGroups(), "", "", "rhel")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -684,18 +684,13 @@ func ostreeCommitPipeline(options distro.ImageOptions, osVersion string) *osbuil
|
|||
p.Build = "name:build"
|
||||
p.AddStage(osbuild.NewOSTreeInitStage(&osbuild.OSTreeInitStageOptions{Path: "/repo"}))
|
||||
|
||||
commitStageInput := new(osbuild.OSTreeCommitStageInput)
|
||||
commitStageInput.Type = "org.osbuild.tree"
|
||||
commitStageInput.Origin = "org.osbuild.pipeline"
|
||||
commitStageInput.References = osbuild.OSTreeCommitStageReferences{"name:ostree-tree"}
|
||||
|
||||
p.AddStage(osbuild.NewOSTreeCommitStage(
|
||||
&osbuild.OSTreeCommitStageOptions{
|
||||
Ref: options.OSTree.Ref,
|
||||
OSVersion: osVersion,
|
||||
Parent: options.OSTree.Parent,
|
||||
},
|
||||
&osbuild.OSTreeCommitStageInputs{Tree: commitStageInput}),
|
||||
"ostree-tree"),
|
||||
)
|
||||
return p
|
||||
}
|
||||
|
|
@ -742,10 +737,7 @@ func containerPipeline(t *imageType, nginxConfigPath, listenPort string) *osbuil
|
|||
ExposedPorts: []string{listenPort},
|
||||
},
|
||||
}
|
||||
baseInput := new(osbuild.OCIArchiveStageInput)
|
||||
baseInput.Type = "org.osbuild.tree"
|
||||
baseInput.Origin = "org.osbuild.pipeline"
|
||||
baseInput.References = []string{"name:container-tree"}
|
||||
baseInput := osbuild.NewTreeInput("name:container-tree")
|
||||
inputs := &osbuild.OCIArchiveStageInputs{Base: baseInput}
|
||||
p.AddStage(osbuild.NewOCIArchiveStage(options, inputs))
|
||||
return p
|
||||
|
|
@ -848,12 +840,12 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string, rn
|
|||
}
|
||||
|
||||
inputName := "root-tree"
|
||||
copyInputs := osbuild.NewCopyStagePipelineTreeInputs(inputName, "efiboot-tree")
|
||||
copyInputs := osbuild.NewPipelineTreeInputs(inputName, "efiboot-tree")
|
||||
copyOptions, copyDevices, copyMounts := osbuild.GenCopyFSTreeOptions(inputName, "efiboot-tree", filename, &pt)
|
||||
p.AddStage(osbuild.NewCopyStage(copyOptions, copyInputs, copyDevices, copyMounts))
|
||||
|
||||
inputName = "coi"
|
||||
copyInputs = osbuild.NewCopyStagePipelineTreeInputs(inputName, "coi-tree")
|
||||
copyInputs = osbuild.NewPipelineTreeInputs(inputName, "coi-tree")
|
||||
p.AddStage(osbuild.NewCopyStageSimple(
|
||||
&osbuild.CopyStageOptions{
|
||||
Paths: []osbuild.CopyStagePath{
|
||||
|
|
@ -871,7 +863,7 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string, rn
|
|||
))
|
||||
|
||||
inputName = "efi-tree"
|
||||
copyInputs = osbuild.NewCopyStagePipelineTreeInputs(inputName, "efiboot-tree")
|
||||
copyInputs = osbuild.NewPipelineTreeInputs(inputName, "efiboot-tree")
|
||||
p.AddStage(osbuild.NewCopyStageSimple(
|
||||
&osbuild.CopyStageOptions{
|
||||
Paths: []osbuild.CopyStagePath{
|
||||
|
|
@ -1090,7 +1082,7 @@ func bootISOPipeline(filename, isolabel, arch string, isolinux bool) *osbuild.Pi
|
|||
p.Name = "bootiso"
|
||||
p.Build = "name:build"
|
||||
|
||||
p.AddStage(osbuild.NewXorrisofsStage(xorrisofsStageOptions(filename, isolabel, arch, isolinux), osbuild.NewXorrisofsStagePipelineTreeInputs("bootiso-tree")))
|
||||
p.AddStage(osbuild.NewXorrisofsStage(xorrisofsStageOptions(filename, isolabel, arch, isolinux), "bootiso-tree"))
|
||||
p.AddStage(osbuild.NewImplantisomd5Stage(&osbuild.Implantisomd5StageOptions{Filename: filename}))
|
||||
|
||||
return p
|
||||
|
|
@ -1107,7 +1099,7 @@ func liveImagePipeline(inputPipelineName string, outputFilename string, pt *disk
|
|||
|
||||
inputName := "root-tree"
|
||||
copyOptions, copyDevices, copyMounts := osbuild.GenCopyFSTreeOptions(inputName, inputPipelineName, outputFilename, pt)
|
||||
copyInputs := osbuild.NewCopyStagePipelineTreeInputs(inputName, inputPipelineName)
|
||||
copyInputs := osbuild.NewPipelineTreeInputs(inputName, inputPipelineName)
|
||||
p.AddStage(osbuild.NewCopyStage(copyOptions, copyInputs, copyDevices, copyMounts))
|
||||
|
||||
for _, stage := range osbuild.GenImageFinishStages(pt, outputFilename) {
|
||||
|
|
@ -1136,7 +1128,7 @@ func tarArchivePipeline(name, inputPipelineName string, tarOptions *osbuild.TarS
|
|||
p := new(osbuild.Pipeline)
|
||||
p.Name = name
|
||||
p.Build = "name:build"
|
||||
p.AddStage(osbuild.NewTarStage(tarOptions, osbuild.NewTarStagePipelineTreeInputs(inputPipelineName)))
|
||||
p.AddStage(osbuild.NewTarStage(tarOptions, inputPipelineName))
|
||||
return p
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,11 +49,6 @@ func (p *OSTreeCommit) serialize() osbuild.Pipeline {
|
|||
|
||||
pipeline.AddStage(osbuild.NewOSTreeInitStage(&osbuild.OSTreeInitStageOptions{Path: "/repo"}))
|
||||
|
||||
commitStageInput := new(osbuild.OSTreeCommitStageInput)
|
||||
commitStageInput.Type = "org.osbuild.tree"
|
||||
commitStageInput.Origin = "org.osbuild.pipeline"
|
||||
commitStageInput.References = osbuild.OSTreeCommitStageReferences{"name:" + p.treePipeline.Name()}
|
||||
|
||||
var parent string
|
||||
if p.treePipeline.OSTree.Parent != nil {
|
||||
parent = p.treePipeline.OSTree.Parent.Checksum
|
||||
|
|
@ -64,7 +59,7 @@ func (p *OSTreeCommit) serialize() osbuild.Pipeline {
|
|||
OSVersion: p.OSVersion,
|
||||
Parent: parent,
|
||||
},
|
||||
&osbuild.OSTreeCommitStageInputs{Tree: commitStageInput}),
|
||||
p.treePipeline.Name()),
|
||||
)
|
||||
|
||||
return pipeline
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ func (p *ISO) getBuildPackages() []string {
|
|||
func (p *ISO) serialize() osbuild.Pipeline {
|
||||
pipeline := p.Base.serialize()
|
||||
|
||||
pipeline.AddStage(osbuild.NewXorrisofsStage(xorrisofsStageOptions(p.Filename, p.treePipeline.isoLabel, p.ISOLinux), osbuild.NewXorrisofsStagePipelineTreeInputs(p.treePipeline.Name())))
|
||||
pipeline.AddStage(osbuild.NewXorrisofsStage(xorrisofsStageOptions(p.Filename, p.treePipeline.isoLabel, p.ISOLinux), p.treePipeline.Name()))
|
||||
pipeline.AddStage(osbuild.NewImplantisomd5Stage(&osbuild.Implantisomd5StageOptions{Filename: p.Filename}))
|
||||
|
||||
return pipeline
|
||||
|
|
|
|||
|
|
@ -43,10 +43,7 @@ func (p *OCIContainer) serialize() osbuild.Pipeline {
|
|||
ExposedPorts: p.ExposedPorts,
|
||||
},
|
||||
}
|
||||
baseInput := new(osbuild.OCIArchiveStageInput)
|
||||
baseInput.Type = "org.osbuild.tree"
|
||||
baseInput.Origin = "org.osbuild.pipeline"
|
||||
baseInput.References = []string{"name:" + p.treePipeline.Name()}
|
||||
baseInput := osbuild.NewTreeInput("name:" + p.treePipeline.Name())
|
||||
inputs := &osbuild.OCIArchiveStageInputs{Base: baseInput}
|
||||
pipeline.AddStage(osbuild.NewOCIArchiveStage(options, inputs))
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ func (p *RawImage) serialize() osbuild.Pipeline {
|
|||
|
||||
inputName := "root-tree"
|
||||
copyOptions, copyDevices, copyMounts := osbuild.GenCopyFSTreeOptions(inputName, p.treePipeline.Name(), p.Filename, pt)
|
||||
copyInputs := osbuild.NewCopyStagePipelineTreeInputs(inputName, p.treePipeline.Name())
|
||||
copyInputs := osbuild.NewPipelineTreeInputs(inputName, p.treePipeline.Name())
|
||||
pipeline.AddStage(osbuild.NewCopyStage(copyOptions, copyInputs, copyDevices, copyMounts))
|
||||
|
||||
for _, stage := range osbuild.GenImageFinishStages(pt, p.Filename) {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ func (p *RawOSTreeImage) serialize() osbuild.Pipeline {
|
|||
|
||||
inputName := "root-tree"
|
||||
copyOptions, copyDevices, copyMounts := osbuild.GenCopyFSTreeOptions(inputName, p.treePipeline.Name(), p.Filename, pt)
|
||||
copyInputs := osbuild.NewCopyStagePipelineTreeInputs(inputName, p.treePipeline.Name())
|
||||
copyInputs := osbuild.NewPipelineTreeInputs(inputName, p.treePipeline.Name())
|
||||
pipeline.AddStage(osbuild.NewCopyStage(copyOptions, copyInputs, copyDevices, copyMounts))
|
||||
|
||||
for _, stage := range osbuild.GenImageFinishStages(pt, p.Filename) {
|
||||
|
|
|
|||
|
|
@ -36,12 +36,7 @@ func NewTar(m *Manifest,
|
|||
func (p *Tar) serialize() osbuild.Pipeline {
|
||||
pipeline := p.Base.serialize()
|
||||
|
||||
tree := new(osbuild.TarStageInput)
|
||||
tree.Type = "org.osbuild.tree"
|
||||
tree.Origin = "org.osbuild.pipeline"
|
||||
tree.References = []string{"name:" + p.inputPipeline.Name()}
|
||||
tarStage := osbuild.NewTarStage(&osbuild.TarStageOptions{Filename: p.Filename}, &osbuild.TarStageInputs{Tree: tree})
|
||||
|
||||
tarStage := osbuild.NewTarStage(&osbuild.TarStageOptions{Filename: p.Filename}, p.inputPipeline.Name())
|
||||
pipeline.AddStage(tarStage)
|
||||
|
||||
return pipeline
|
||||
|
|
|
|||
|
|
@ -62,23 +62,12 @@ func BCJOption(arch string) string {
|
|||
func (BootISOMonoStageOptions) isStageOptions() {}
|
||||
|
||||
type BootISOMonoStageInputs struct {
|
||||
RootFS *BootISOMonoStageInput `json:"rootfs"`
|
||||
Kernel *BootISOMonoStageInput `json:"kernel,omitempty"`
|
||||
RootFS *TreeInput `json:"rootfs"`
|
||||
Kernel *TreeInput `json:"kernel,omitempty"`
|
||||
}
|
||||
|
||||
func (BootISOMonoStageInputs) isStageInputs() {}
|
||||
|
||||
type BootISOMonoStageInput struct {
|
||||
inputCommon
|
||||
References BootISOMonoStageReferences `json:"references"`
|
||||
}
|
||||
|
||||
func (BootISOMonoStageInput) isStageInput() {}
|
||||
|
||||
type BootISOMonoStageReferences []string
|
||||
|
||||
func (BootISOMonoStageReferences) isReferences() {}
|
||||
|
||||
// Assemble a file system tree for a bootable ISO
|
||||
func NewBootISOMonoStage(options *BootISOMonoStageOptions, inputs *BootISOMonoStageInputs) *Stage {
|
||||
return &Stage{
|
||||
|
|
@ -89,10 +78,7 @@ func NewBootISOMonoStage(options *BootISOMonoStageOptions, inputs *BootISOMonoSt
|
|||
}
|
||||
|
||||
func NewBootISOMonoStagePipelineTreeInputs(pipeline string) *BootISOMonoStageInputs {
|
||||
rootfsInput := new(BootISOMonoStageInput)
|
||||
rootfsInput.Type = "org.osbuild.tree"
|
||||
rootfsInput.Origin = "org.osbuild.pipeline"
|
||||
rootfsInput.References = BootISOMonoStageReferences{"name:" + pipeline}
|
||||
rootfsInput := NewTreeInput("name:" + pipeline)
|
||||
return &BootISOMonoStageInputs{
|
||||
RootFS: rootfsInput,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,59 +21,24 @@ type CopyStagePath struct {
|
|||
|
||||
func (CopyStageOptions) isStageOptions() {}
|
||||
|
||||
type CopyStageInputs map[string]CopyStageInput
|
||||
|
||||
type CopyStageInput struct {
|
||||
inputCommon
|
||||
References CopyStageReferences `json:"references"`
|
||||
}
|
||||
|
||||
func (CopyStageInputs) isStageInputs() {}
|
||||
|
||||
type CopyStageReferences []string
|
||||
|
||||
type CopyStageInputsNew interface {
|
||||
isCopyStageInputs()
|
||||
}
|
||||
|
||||
func (CopyStageInputs) isCopyStageInputs() {}
|
||||
|
||||
func (CopyStageReferences) isReferences() {}
|
||||
|
||||
func NewCopyStage(options *CopyStageOptions, inputs CopyStageInputsNew, devices *Devices, mounts *Mounts) *Stage {
|
||||
var stageInputs Inputs
|
||||
if inputs != nil {
|
||||
stageInputs = inputs.(Inputs)
|
||||
}
|
||||
func NewCopyStage(options *CopyStageOptions, inputs Inputs, devices *Devices, mounts *Mounts) *Stage {
|
||||
return &Stage{
|
||||
Type: "org.osbuild.copy",
|
||||
Options: options,
|
||||
Inputs: stageInputs,
|
||||
Inputs: inputs,
|
||||
Devices: *devices,
|
||||
Mounts: *mounts,
|
||||
}
|
||||
}
|
||||
|
||||
func NewCopyStageSimple(options *CopyStageOptions, inputs CopyStageInputsNew) *Stage {
|
||||
var stageInputs Inputs
|
||||
if inputs != nil {
|
||||
stageInputs = inputs.(Inputs)
|
||||
}
|
||||
func NewCopyStageSimple(options *CopyStageOptions, inputs Inputs) *Stage {
|
||||
return &Stage{
|
||||
Type: "org.osbuild.copy",
|
||||
Options: options,
|
||||
Inputs: stageInputs,
|
||||
Inputs: inputs,
|
||||
}
|
||||
}
|
||||
|
||||
func NewCopyStagePipelineTreeInputs(inputName, inputPipeline string) *CopyStageInputs {
|
||||
treeInput := CopyStageInput{}
|
||||
treeInput.Type = "org.osbuild.tree"
|
||||
treeInput.Origin = "org.osbuild.pipeline"
|
||||
treeInput.References = []string{"name:" + inputPipeline}
|
||||
return &CopyStageInputs{inputName: treeInput}
|
||||
}
|
||||
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -29,20 +29,20 @@ func TestNewCopyStage(t *testing.T) {
|
|||
*NewBtrfsMount("root", "root", "/"),
|
||||
}
|
||||
|
||||
treeInput := CopyStageInput{}
|
||||
treeInput := TreeInput{}
|
||||
treeInput.Type = "org.osbuild.tree"
|
||||
treeInput.Origin = "org.osbuild.pipeline"
|
||||
treeInput.References = []string{"name:input-pipeline"}
|
||||
expectedStage := &Stage{
|
||||
Type: "org.osbuild.copy",
|
||||
Options: &CopyStageOptions{paths},
|
||||
Inputs: &CopyStageInputs{"tree-input": treeInput},
|
||||
Inputs: &PipelineTreeInputs{"tree-input": treeInput},
|
||||
Devices: devices,
|
||||
Mounts: mounts,
|
||||
}
|
||||
// convert to alias types
|
||||
stageMounts := Mounts(mounts)
|
||||
stageDevices := Devices(devices)
|
||||
actualStage := NewCopyStage(&CopyStageOptions{paths}, &CopyStageInputs{"tree-input": treeInput}, &stageDevices, &stageMounts)
|
||||
actualStage := NewCopyStage(&CopyStageOptions{paths}, NewPipelineTreeInputs("tree-input", "input-pipeline"), &stageDevices, &stageMounts)
|
||||
assert.Equal(t, expectedStage, actualStage)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,9 +24,6 @@ func NewFilesInputs(references FilesInputReferences) *FilesInputs {
|
|||
// inputs accepted by the XZ stage
|
||||
func (FilesInputs) isXzStageInputs() {}
|
||||
|
||||
// inputs accepted by the Copy stage
|
||||
func (FilesInputs) isCopyStageInputs() {}
|
||||
|
||||
// SPECIFIC INPUT STRUCTURE
|
||||
|
||||
type FilesInput struct {
|
||||
|
|
|
|||
|
|
@ -34,24 +34,13 @@ func (OCIArchiveStageOptions) isStageOptions() {}
|
|||
|
||||
type OCIArchiveStageInputs struct {
|
||||
// Base layer for the container
|
||||
Base *OCIArchiveStageInput `json:"base"`
|
||||
Base *TreeInput `json:"base"`
|
||||
// Additional layers in ascending order
|
||||
Layers []OCIArchiveStageInput `json:",omitempty"`
|
||||
Layers []TreeInput `json:",omitempty"`
|
||||
}
|
||||
|
||||
func (OCIArchiveStageInputs) isStageInputs() {}
|
||||
|
||||
type OCIArchiveStageInput struct {
|
||||
inputCommon
|
||||
References OCIArchiveStageReferences `json:"references"`
|
||||
}
|
||||
|
||||
func (OCIArchiveStageInput) isStageInput() {}
|
||||
|
||||
type OCIArchiveStageReferences []string
|
||||
|
||||
func (OCIArchiveStageReferences) isReferences() {}
|
||||
|
||||
// A new OCIArchiveStage to to assemble an OCI image archive
|
||||
func NewOCIArchiveStage(options *OCIArchiveStageOptions, inputs *OCIArchiveStageInputs) *Stage {
|
||||
return &Stage{
|
||||
|
|
@ -69,7 +58,7 @@ func (inputs *OCIArchiveStageInputs) MarshalJSON() ([]byte, error) {
|
|||
}
|
||||
|
||||
layers := inputs.Layers
|
||||
inputsMap := make(map[string]OCIArchiveStageInput, len(layers)+1)
|
||||
inputsMap := make(map[string]TreeInput, len(layers)+1)
|
||||
if inputs.Base != nil {
|
||||
inputsMap["base"] = *inputs.Base
|
||||
}
|
||||
|
|
@ -83,7 +72,7 @@ func (inputs *OCIArchiveStageInputs) MarshalJSON() ([]byte, error) {
|
|||
}
|
||||
|
||||
// Get the sorted keys that match the pattern "layer.N" (for N > 0)
|
||||
func layerKeys(layers map[string]OCIArchiveStageInput) ([]string, error) {
|
||||
func layerKeys(layers map[string]TreeInput) ([]string, error) {
|
||||
keys := make([]string, 0, len(layers))
|
||||
for key := range layers {
|
||||
re := regexp.MustCompile(`layer\.[1-9]\d*`)
|
||||
|
|
@ -110,7 +99,7 @@ func (inputs *OCIArchiveStageInputs) UnmarshalJSON(data []byte) error {
|
|||
inputs = new(OCIArchiveStageInputs)
|
||||
}
|
||||
|
||||
inputsMap := make(map[string]OCIArchiveStageInput)
|
||||
inputsMap := make(map[string]TreeInput)
|
||||
|
||||
dec := json.NewDecoder(bytes.NewReader(data))
|
||||
dec.DisallowUnknownFields()
|
||||
|
|
@ -130,7 +119,7 @@ func (inputs *OCIArchiveStageInputs) UnmarshalJSON(data []byte) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
inputs.Layers = make([]OCIArchiveStageInput, len(inputsMap)-1)
|
||||
inputs.Layers = make([]TreeInput, len(inputsMap)-1)
|
||||
for idx, key := range keys {
|
||||
inputs.Layers[idx] = inputsMap[key]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ func TestOCIArchiveInputs(t *testing.T) {
|
|||
}
|
||||
}`
|
||||
inputs := new(OCIArchiveStageInputs)
|
||||
base := &OCIArchiveStageInput{
|
||||
base := &TreeInput{
|
||||
References: []string{
|
||||
"name:container-tree",
|
||||
},
|
||||
|
|
@ -44,14 +44,14 @@ func TestOCIArchiveInputs(t *testing.T) {
|
|||
base.Type = "org.osbuild.oci-archive"
|
||||
base.Origin = "org.osbuild.pipeline"
|
||||
|
||||
layer1 := OCIArchiveStageInput{
|
||||
layer1 := TreeInput{
|
||||
References: []string{
|
||||
"name:container-ostree",
|
||||
},
|
||||
}
|
||||
layer1.Type = "org.osbuild.tree"
|
||||
layer1.Origin = "org.osbuild.pipeline"
|
||||
layer2 := OCIArchiveStageInput{
|
||||
layer2 := TreeInput{
|
||||
References: []string{
|
||||
"name:container-ostree2",
|
||||
},
|
||||
|
|
@ -60,7 +60,7 @@ func TestOCIArchiveInputs(t *testing.T) {
|
|||
layer2.Origin = "org.osbuild.pipeline"
|
||||
|
||||
inputs.Base = base
|
||||
inputs.Layers = []OCIArchiveStageInput{layer1, layer2}
|
||||
inputs.Layers = []TreeInput{layer1, layer2}
|
||||
|
||||
data, err := json.Marshal(inputs)
|
||||
assert.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -13,30 +13,13 @@ type OSTreeCommitStageOptions struct {
|
|||
|
||||
func (OSTreeCommitStageOptions) isStageOptions() {}
|
||||
|
||||
type OSTreeCommitStageInput struct {
|
||||
inputCommon
|
||||
References OSTreeCommitStageReferences `json:"references"`
|
||||
}
|
||||
|
||||
func (OSTreeCommitStageInput) isStageInput() {}
|
||||
|
||||
type OSTreeCommitStageInputs struct {
|
||||
Tree *OSTreeCommitStageInput `json:"tree"`
|
||||
}
|
||||
|
||||
func (OSTreeCommitStageInputs) isStageInputs() {}
|
||||
|
||||
type OSTreeCommitStageReferences []string
|
||||
|
||||
func (OSTreeCommitStageReferences) isReferences() {}
|
||||
|
||||
// The OSTreeCommitStage (org.osbuild.ostree.commit) describes how to assemble
|
||||
// a tree into an OSTree commit.
|
||||
func NewOSTreeCommitStage(options *OSTreeCommitStageOptions, inputs *OSTreeCommitStageInputs) *Stage {
|
||||
func NewOSTreeCommitStage(options *OSTreeCommitStageOptions, inputPipeline string) *Stage {
|
||||
return &Stage{
|
||||
Type: "org.osbuild.ostree.commit",
|
||||
Options: options,
|
||||
Inputs: inputs,
|
||||
Inputs: NewPipelineTreeInputs("tree", inputPipeline),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,26 +84,9 @@ func (o TarStageOptions) validate() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
type TarStageInput struct {
|
||||
inputCommon
|
||||
References TarStageReferences `json:"references"`
|
||||
}
|
||||
|
||||
func (TarStageInput) isStageInput() {}
|
||||
|
||||
type TarStageInputs struct {
|
||||
Tree *TarStageInput `json:"tree"`
|
||||
}
|
||||
|
||||
func (TarStageInputs) isStageInputs() {}
|
||||
|
||||
type TarStageReferences []string
|
||||
|
||||
func (TarStageReferences) isReferences() {}
|
||||
|
||||
// Assembles a tree into a tar archive. Compression is determined by the suffix
|
||||
// (i.e., --auto-compress is used).
|
||||
func NewTarStage(options *TarStageOptions, inputs *TarStageInputs) *Stage {
|
||||
func NewTarStage(options *TarStageOptions, inputPipeline string) *Stage {
|
||||
if err := options.validate(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
@ -111,16 +94,6 @@ func NewTarStage(options *TarStageOptions, inputs *TarStageInputs) *Stage {
|
|||
return &Stage{
|
||||
Type: "org.osbuild.tar",
|
||||
Options: options,
|
||||
Inputs: inputs,
|
||||
}
|
||||
}
|
||||
|
||||
func NewTarStagePipelineTreeInputs(pipeline string) *TarStageInputs {
|
||||
tree := new(TarStageInput)
|
||||
tree.Type = "org.osbuild.tree"
|
||||
tree.Origin = "org.osbuild.pipeline"
|
||||
tree.References = []string{"name:" + pipeline}
|
||||
return &TarStageInputs{
|
||||
Tree: tree,
|
||||
Inputs: NewPipelineTreeInputs("tree", inputPipeline),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,13 +8,22 @@ import (
|
|||
|
||||
func TestNewTarStage(t *testing.T) {
|
||||
stageOptions := &TarStageOptions{Filename: "archive.tar.xz"}
|
||||
stageInputs := &TarStageInputs{}
|
||||
stageInputs := &PipelineTreeInputs{"tree": TreeInput{
|
||||
inputCommon: inputCommon{
|
||||
Type: "org.osbuild.tree",
|
||||
Origin: "org.osbuild.pipeline",
|
||||
},
|
||||
References: []string{
|
||||
"name:pipeline33",
|
||||
},
|
||||
},
|
||||
}
|
||||
expectedStage := &Stage{
|
||||
Type: "org.osbuild.tar",
|
||||
Options: stageOptions,
|
||||
Inputs: stageInputs,
|
||||
}
|
||||
actualStage := NewTarStage(stageOptions, stageInputs)
|
||||
actualStage := NewTarStage(stageOptions, "pipeline33")
|
||||
assert.Equal(t, expectedStage, actualStage)
|
||||
}
|
||||
|
||||
|
|
@ -59,10 +68,10 @@ func TestTarStageOptionsValidate(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
if tt.err {
|
||||
assert.Errorf(t, tt.options.validate(), "%q didn't return an error [idx: %d]", tt.name, idx)
|
||||
assert.Panics(t, func() { NewTarStage(&tt.options, &TarStageInputs{}) })
|
||||
assert.Panics(t, func() { NewTarStage(&tt.options, "") })
|
||||
} else {
|
||||
assert.NoErrorf(t, tt.options.validate(), "%q returned an error [idx: %d]", tt.name, idx)
|
||||
assert.NotPanics(t, func() { NewTarStage(&tt.options, &TarStageInputs{}) })
|
||||
assert.NotPanics(t, func() { NewTarStage(&tt.options, "") })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,36 +30,11 @@ type XorrisofsBoot struct {
|
|||
|
||||
func (XorrisofsStageOptions) isStageOptions() {}
|
||||
|
||||
type XorrisofsStageInputs struct {
|
||||
Tree *XorrisofsStageInput `json:"tree"`
|
||||
}
|
||||
|
||||
func (XorrisofsStageInputs) isStageInputs() {}
|
||||
|
||||
type XorrisofsStageInput struct {
|
||||
inputCommon
|
||||
References XorrisofsStageReferences `json:"references"`
|
||||
}
|
||||
|
||||
func (XorrisofsStageInput) isStageInput() {}
|
||||
|
||||
type XorrisofsStageReferences []string
|
||||
|
||||
func (XorrisofsStageReferences) isReferences() {}
|
||||
|
||||
// Assembles a Rock Ridge enhanced ISO 9660 filesystem (iso)
|
||||
func NewXorrisofsStage(options *XorrisofsStageOptions, inputs *XorrisofsStageInputs) *Stage {
|
||||
func NewXorrisofsStage(options *XorrisofsStageOptions, inputPipeline string) *Stage {
|
||||
return &Stage{
|
||||
Type: "org.osbuild.xorrisofs",
|
||||
Options: options,
|
||||
Inputs: inputs,
|
||||
Inputs: NewPipelineTreeInputs("tree", inputPipeline),
|
||||
}
|
||||
}
|
||||
|
||||
func NewXorrisofsStagePipelineTreeInputs(pipeline string) *XorrisofsStageInputs {
|
||||
input := new(XorrisofsStageInput)
|
||||
input.Type = "org.osbuild.tree"
|
||||
input.Origin = "org.osbuild.pipeline"
|
||||
input.References = XorrisofsStageReferences{"name:" + pipeline}
|
||||
return &XorrisofsStageInputs{Tree: input}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue