-
Notifications
You must be signed in to change notification settings - Fork 47
/
commit.go
65 lines (54 loc) · 1.49 KB
/
commit.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
64
65
package manifest
import (
"github.com/osbuild/images/pkg/osbuild"
)
// OSTreeCommit represents an ostree with one commit.
type OSTreeCommit struct {
Base
OSVersion string
treePipeline *OS
ref string
}
// NewOSTreeCommit creates a new OSTree commit pipeline. The
// treePipeline is the tree representing the content of the commit.
// ref is the ref to create the commit under.
func NewOSTreeCommit(buildPipeline Build, treePipeline *OS, ref string) *OSTreeCommit {
p := &OSTreeCommit{
Base: NewBase("ostree-commit", buildPipeline),
treePipeline: treePipeline,
ref: ref,
}
buildPipeline.addDependent(p)
return p
}
func (p *OSTreeCommit) getBuildPackages(Distro) []string {
packages := []string{
"rpm-ostree",
}
return packages
}
func (p *OSTreeCommit) serialize() osbuild.Pipeline {
pipeline := p.Base.serialize()
if p.treePipeline.OSTreeRef == "" {
panic("tree is not ostree")
}
pipeline.AddStage(osbuild.NewOSTreeInitStage(&osbuild.OSTreeInitStageOptions{Path: "/repo"}))
var parentID string
treeCommits := p.treePipeline.getOSTreeCommits()
if len(treeCommits) > 0 {
if len(treeCommits) > 1 {
panic("multiple ostree commit specs found; this is a programming error")
}
parentCommit := &treeCommits[0]
parentID = parentCommit.Checksum
}
pipeline.AddStage(osbuild.NewOSTreeCommitStage(
&osbuild.OSTreeCommitStageOptions{
Ref: p.ref,
OSVersion: p.OSVersion,
Parent: parentID,
},
p.treePipeline.Name()),
)
return pipeline
}