forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefaults.go
53 lines (46 loc) · 1.35 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
package v1
import "k8s.io/kubernetes/pkg/runtime"
// If adding or changing route defaults, updates may be required to
// pkg/router/controller/controller.go to ensure the routes generated from
// ingress resources will match routes created via the api.
func SetDefaults_RouteSpec(obj *RouteSpec) {
if len(obj.WildcardPolicy) == 0 {
obj.WildcardPolicy = WildcardPolicyNone
}
}
func SetDefaults_RouteTargetReference(obj *RouteTargetReference) {
if len(obj.Kind) == 0 {
obj.Kind = "Service"
}
if obj.Weight == nil {
obj.Weight = new(int32)
*obj.Weight = 100
}
}
func SetDefaults_TLSConfig(obj *TLSConfig) {
if len(obj.Termination) == 0 && len(obj.DestinationCACertificate) == 0 {
obj.Termination = TLSTerminationEdge
}
switch obj.Termination {
case TLSTerminationType("Reencrypt"):
obj.Termination = TLSTerminationReencrypt
case TLSTerminationType("Edge"):
obj.Termination = TLSTerminationEdge
case TLSTerminationType("Passthrough"):
obj.Termination = TLSTerminationPassthrough
}
}
func SetDefaults_RouteIngress(obj *RouteIngress) {
if len(obj.WildcardPolicy) == 0 {
obj.WildcardPolicy = WildcardPolicyNone
}
}
func addDefaultingFuncs(scheme *runtime.Scheme) error {
RegisterDefaults(scheme)
return scheme.AddDefaultingFuncs(
SetDefaults_RouteSpec,
SetDefaults_RouteTargetReference,
SetDefaults_TLSConfig,
SetDefaults_RouteIngress,
)
}