-
Notifications
You must be signed in to change notification settings - Fork 0
/
defaults.go
57 lines (48 loc) · 1.49 KB
/
defaults.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
package v1
import "k8s.io/kubernetes/pkg/runtime"
func SetDefaults_BuildConfigSpec(config *BuildConfigSpec) {
if len(config.RunPolicy) == 0 {
config.RunPolicy = BuildRunPolicySerial
}
}
func SetDefaults_BuildSource(source *BuildSource) {
if (source != nil) && (source.Type == BuildSourceBinary) && (source.Binary == nil) {
source.Binary = &BinaryBuildSource{}
}
}
func SetDefaults_BuildStrategy(strategy *BuildStrategy) {
if (strategy != nil) && (strategy.Type == DockerBuildStrategyType) && (strategy.DockerStrategy == nil) {
strategy.DockerStrategy = &DockerBuildStrategy{}
}
}
func SetDefaults_SourceBuildStrategy(obj *SourceBuildStrategy) {
if len(obj.From.Kind) == 0 {
obj.From.Kind = "ImageStreamTag"
}
}
func SetDefaults_DockerBuildStrategy(obj *DockerBuildStrategy) {
if obj.From != nil && len(obj.From.Kind) == 0 {
obj.From.Kind = "ImageStreamTag"
}
}
func SetDefaults_CustomBuildStrategy(obj *CustomBuildStrategy) {
if len(obj.From.Kind) == 0 {
obj.From.Kind = "ImageStreamTag"
}
}
func SetDefaults_BuildTriggerPolicy(obj *BuildTriggerPolicy) {
if obj.Type == ImageChangeBuildTriggerType && obj.ImageChange == nil {
obj.ImageChange = &ImageChangeTrigger{}
}
}
func addDefaultingFuncs(scheme *runtime.Scheme) error {
return scheme.AddDefaultingFuncs(
SetDefaults_BuildConfigSpec,
SetDefaults_BuildSource,
SetDefaults_BuildStrategy,
SetDefaults_SourceBuildStrategy,
SetDefaults_DockerBuildStrategy,
SetDefaults_CustomBuildStrategy,
SetDefaults_BuildTriggerPolicy,
)
}