-
Notifications
You must be signed in to change notification settings - Fork 46
/
oci_container.go
63 lines (52 loc) · 1.52 KB
/
oci_container.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package manifest
import (
"github.com/osbuild/images/pkg/artifact"
"github.com/osbuild/images/pkg/osbuild"
)
// An OCIContainer represents an OCI container, containing a filesystem
// tree created by another Pipeline.
type OCIContainer struct {
Base
filename string
Cmd []string
ExposedPorts []string
treePipeline TreePipeline
}
func (p OCIContainer) Filename() string {
return p.filename
}
func (p *OCIContainer) SetFilename(filename string) {
p.filename = filename
}
func NewOCIContainer(buildPipeline Build, treePipeline TreePipeline) *OCIContainer {
p := &OCIContainer{
Base: NewBase("container", buildPipeline),
treePipeline: treePipeline,
filename: "oci-archive.tar",
}
buildPipeline.addDependent(p)
return p
}
func (p *OCIContainer) serialize() osbuild.Pipeline {
pipeline := p.Base.serialize()
options := &osbuild.OCIArchiveStageOptions{
Architecture: p.treePipeline.Platform().GetArch().String(),
Filename: p.Filename(),
Config: &osbuild.OCIArchiveConfig{
Cmd: p.Cmd,
ExposedPorts: p.ExposedPorts,
},
}
baseInput := osbuild.NewTreeInput("name:" + p.treePipeline.Name())
inputs := &osbuild.OCIArchiveStageInputs{Base: baseInput}
pipeline.AddStage(osbuild.NewOCIArchiveStage(options, inputs))
return pipeline
}
func (p *OCIContainer) getBuildPackages(Distro) []string {
return []string{"tar"}
}
func (p *OCIContainer) Export() *artifact.Artifact {
p.Base.export = true
mimeType := "application/x-tar"
return artifact.New(p.Name(), p.Filename(), &mimeType)
}