forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conversions.go
155 lines (152 loc) · 4.45 KB
/
conversions.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package v1
import (
"k8s.io/kubernetes/pkg/conversion"
newer "github.com/openshift/origin/pkg/cmd/server/api"
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy"
)
func init() {
err := newer.Scheme.AddDefaultingFuncs(
func(obj *MasterConfig) {
if len(obj.APILevels) == 0 {
obj.APILevels = newer.DefaultOpenShiftAPILevels
}
if len(obj.Controllers) == 0 {
obj.Controllers = ControllersAll
}
if obj.ServingInfo.RequestTimeoutSeconds == 0 {
obj.ServingInfo.RequestTimeoutSeconds = 60 * 60
}
if obj.ServingInfo.MaxRequestsInFlight == 0 {
obj.ServingInfo.MaxRequestsInFlight = 500
}
if len(obj.PolicyConfig.OpenShiftInfrastructureNamespace) == 0 {
obj.PolicyConfig.OpenShiftInfrastructureNamespace = bootstrappolicy.DefaultOpenShiftInfraNamespace
}
if len(obj.RoutingConfig.Subdomain) == 0 {
obj.RoutingConfig.Subdomain = "router.default.svc.cluster.local"
}
},
func(obj *KubernetesMasterConfig) {
if obj.MasterCount == 0 {
obj.MasterCount = 1
}
if len(obj.APILevels) == 0 {
obj.APILevels = newer.DefaultKubernetesAPILevels
}
if len(obj.ServicesNodePortRange) == 0 {
obj.ServicesNodePortRange = "30000-32767"
}
if len(obj.PodEvictionTimeout) == 0 {
obj.PodEvictionTimeout = "5m"
}
},
func(obj *EtcdStorageConfig) {
if len(obj.KubernetesStorageVersion) == 0 {
obj.KubernetesStorageVersion = "v1"
}
if len(obj.KubernetesStoragePrefix) == 0 {
obj.KubernetesStoragePrefix = "kubernetes.io"
}
if len(obj.OpenShiftStorageVersion) == 0 {
obj.OpenShiftStorageVersion = "v1"
}
if len(obj.OpenShiftStoragePrefix) == 0 {
obj.OpenShiftStoragePrefix = "openshift.io"
}
},
func(obj *DockerConfig) {
if len(obj.ExecHandlerName) == 0 {
obj.ExecHandlerName = DockerExecHandlerNative
}
},
func(obj *ServingInfo) {
if len(obj.BindNetwork) == 0 {
obj.BindNetwork = "tcp4"
}
},
func(obj *DNSConfig) {
if len(obj.BindNetwork) == 0 {
obj.BindNetwork = "tcp4"
}
},
func(obj *SecurityAllocator) {
if len(obj.UIDAllocatorRange) == 0 {
obj.UIDAllocatorRange = "1000000000-1999999999/10000"
}
if len(obj.MCSAllocatorRange) == 0 {
obj.MCSAllocatorRange = "s0:/2"
}
if obj.MCSLabelsPerProject == 0 {
obj.MCSLabelsPerProject = 5
}
},
)
if err != nil {
// If one of the conversion functions is malformed, detect it immediately.
panic(err)
}
err = newer.Scheme.AddConversionFuncs(
func(in *ServingInfo, out *newer.ServingInfo, s conversion.Scope) error {
out.BindAddress = in.BindAddress
out.BindNetwork = in.BindNetwork
out.ClientCA = in.ClientCA
out.ServerCert.CertFile = in.CertFile
out.ServerCert.KeyFile = in.KeyFile
return nil
},
func(in *newer.ServingInfo, out *ServingInfo, s conversion.Scope) error {
out.BindAddress = in.BindAddress
out.BindNetwork = in.BindNetwork
out.ClientCA = in.ClientCA
out.CertFile = in.ServerCert.CertFile
out.KeyFile = in.ServerCert.KeyFile
return nil
},
func(in *RemoteConnectionInfo, out *newer.RemoteConnectionInfo, s conversion.Scope) error {
out.URL = in.URL
out.CA = in.CA
out.ClientCert.CertFile = in.CertFile
out.ClientCert.KeyFile = in.KeyFile
return nil
},
func(in *newer.RemoteConnectionInfo, out *RemoteConnectionInfo, s conversion.Scope) error {
out.URL = in.URL
out.CA = in.CA
out.CertFile = in.ClientCert.CertFile
out.KeyFile = in.ClientCert.KeyFile
return nil
},
func(in *EtcdConnectionInfo, out *newer.EtcdConnectionInfo, s conversion.Scope) error {
out.URLs = in.URLs
out.CA = in.CA
out.ClientCert.CertFile = in.CertFile
out.ClientCert.KeyFile = in.KeyFile
return nil
},
func(in *newer.EtcdConnectionInfo, out *EtcdConnectionInfo, s conversion.Scope) error {
out.URLs = in.URLs
out.CA = in.CA
out.CertFile = in.ClientCert.CertFile
out.KeyFile = in.ClientCert.KeyFile
return nil
},
func(in *KubeletConnectionInfo, out *newer.KubeletConnectionInfo, s conversion.Scope) error {
out.Port = in.Port
out.CA = in.CA
out.ClientCert.CertFile = in.CertFile
out.ClientCert.KeyFile = in.KeyFile
return nil
},
func(in *newer.KubeletConnectionInfo, out *KubeletConnectionInfo, s conversion.Scope) error {
out.Port = in.Port
out.CA = in.CA
out.CertFile = in.ClientCert.CertFile
out.KeyFile = in.ClientCert.KeyFile
return nil
},
)
if err != nil {
// If one of the conversion functions is malformed, detect it immediately.
panic(err)
}
}