debian-forge-composer/internal/manifest/tar.go
Achilleas Koutsou 3d772b6846 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.
2022-09-29 18:09:38 +02:00

53 lines
1.3 KiB
Go

package manifest
import (
"github.com/osbuild/osbuild-composer/internal/artifact"
"github.com/osbuild/osbuild-composer/internal/osbuild"
)
// A Tar represents the contents of another pipeline in a tar file
type Tar struct {
Base
Filename string
inputPipeline *Base
}
// NewTar creates a new TarPipeline. The inputPipeline represents the
// filesystem tree which will be the contents of the tar file. The pipelinename
// is the name of the pipeline. The filename is the name of the output tar file.
func NewTar(m *Manifest,
buildPipeline *Build,
inputPipeline *Base,
pipelinename string) *Tar {
p := &Tar{
Base: NewBase(m, pipelinename, buildPipeline),
inputPipeline: inputPipeline,
Filename: "image.tar",
}
if inputPipeline.manifest != m {
panic("tree pipeline from different manifest")
}
buildPipeline.addDependent(p)
m.addPipeline(p)
return p
}
func (p *Tar) serialize() osbuild.Pipeline {
pipeline := p.Base.serialize()
tarStage := osbuild.NewTarStage(&osbuild.TarStageOptions{Filename: p.Filename}, p.inputPipeline.Name())
pipeline.AddStage(tarStage)
return pipeline
}
func (p *Tar) getBuildPackages() []string {
return []string{"tar"}
}
func (p *Tar) Export() *artifact.Artifact {
p.Base.export = true
mimeType := "application/x-tar"
return artifact.New(p.Name(), p.Filename, &mimeType)
}