blob: 98c560cdb6255954054e750b1f93877838fff91c (
plain)
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 config
import (
"gerrit.wikimedia.org/r/blubber/build"
)
// BuilderConfig contains configuration for the definition of an arbitrary
// build command.
//
type BuilderConfig struct {
Builder []string `yaml:"builder"`
}
// Merge takes another BuilderConfig and merges its fields into this one's,
// overwriting the builder command.
//
func (bc *BuilderConfig) Merge(bc2 BuilderConfig) {
if len(bc2.Builder) > 0 {
bc.Builder = bc2.Builder
}
}
// InstructionsForPhase injects instructions into the build related to
// builder commands.
//
// PhasePostInstall
//
// Runs build command provided for the builder
//
func (bc BuilderConfig) InstructionsForPhase(phase build.Phase) []build.Instruction {
switch phase {
case build.PhasePostInstall:
if len(bc.Builder) == 0 {
return []build.Instruction{}
}
run := build.Run{Command: bc.Builder[0]}
if len(bc.Builder) > 1 {
run.Arguments = bc.Builder[1:]
}
return []build.Instruction{run}
}
return []build.Instruction{}
}
|