-
Notifications
You must be signed in to change notification settings - Fork 43
/
osbuild.go
47 lines (40 loc) · 1.42 KB
/
osbuild.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
// Package osbuild provides primitives for representing and (un)marshalling
// OSBuild (schema v2) types.
package osbuild
// A Manifest represents an OSBuild source and pipeline manifest
type Manifest struct {
Version string `json:"version"`
Pipelines []Pipeline `json:"pipelines"`
Sources Sources `json:"sources"`
}
// A Pipeline represents an OSBuild pipeline
type Pipeline struct {
Name string `json:"name,omitempty"`
// The build environment which can run this pipeline
Build string `json:"build,omitempty"`
Runner string `json:"runner,omitempty"`
// Sequence of stages that produce the filesystem tree, which is the
// payload of the produced image.
Stages []*Stage `json:"stages,omitempty"`
}
// SetBuild sets the pipeline and runner for generating the build environment
// for a pipeline.
func (p *Pipeline) SetBuild(build string) {
p.Build = build
}
// AddStage appends a stage to the list of stages of a pipeline. The stages
// will be executed in the order they are appended.
// If the argument is nil, it is not added.
func (p *Pipeline) AddStage(stage *Stage) {
if stage != nil {
p.Stages = append(p.Stages, stage)
}
}
// AddStages appends multiple stages to the list of stages of a pipeline. The
// stages will be executed in the order they are appended.
// If the argument is nil, it is not added.
func (p *Pipeline) AddStages(stages ...*Stage) {
for _, stage := range stages {
p.AddStage(stage)
}
}