debian-forge-composer/internal/manifest/xz.go
Tomáš Hozza dd59ce6a16 osbuild: rework XZ stage inputs
The `FilesInputs` was since the beginning an XZ-specific implementation
of the input, but it was implemented in the `files_input.go` in a false
hope that it could be used as a generic stage inputs by any stages. It
turned out that various stages require different implementation of
its input. Specifically there is usually a stage-specific key, which has
assigned a common input type. For XZ stage, the key is `file`.

Remove `FilesInputs` and instead implement `XzStageInputs` which is now
accepted by the XZ stage.

Fix all affected pipeline implementations that use XZ stage.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-01-30 11:24:08 +01:00

50 lines
1.1 KiB
Go

package manifest
import (
"github.com/osbuild/osbuild-composer/internal/artifact"
"github.com/osbuild/osbuild-composer/internal/osbuild"
)
// The XZ pipeline compresses a raw image file using xz.
type XZ struct {
Base
Filename string
imgPipeline Pipeline
}
// NewXZ creates a new XZ pipeline. imgPipeline is the pipeline producing the
// raw image that will be xz compressed.
func NewXZ(m *Manifest,
buildPipeline *Build,
imgPipeline Pipeline) *XZ {
p := &XZ{
Base: NewBase(m, "xz", buildPipeline),
Filename: "image.xz",
imgPipeline: imgPipeline,
}
buildPipeline.addDependent(p)
m.addPipeline(p)
return p
}
func (p *XZ) serialize() osbuild.Pipeline {
pipeline := p.Base.serialize()
pipeline.AddStage(osbuild.NewXzStage(
osbuild.NewXzStageOptions(p.Filename),
osbuild.NewXzStageInputs(osbuild.NewFilesInputPipelineObjectRef(p.imgPipeline.Name(), p.imgPipeline.Export().Filename(), nil)),
))
return pipeline
}
func (p *XZ) getBuildPackages() []string {
return []string{"xz"}
}
func (p *XZ) Export() *artifact.Artifact {
p.Base.export = true
mimeType := "application/xz"
return artifact.New(p.Name(), p.Filename, &mimeType)
}