forked from projectatomic/atomic-enterprise
/
conversions.go
97 lines (94 loc) · 2.8 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
package v1
import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/conversion"
newer "github.com/openshift/origin/pkg/cmd/server/api"
)
func init() {
err := newer.Scheme.AddDefaultingFuncs(
func(obj *KubernetesMasterConfig) {
if obj.MasterCount == 0 {
obj.MasterCount = 1
}
},
func(obj *EtcdStorageConfig) {
if len(obj.KubernetesStorageVersion) == 0 {
obj.KubernetesStorageVersion = "v1beta3"
}
if len(obj.KubernetesStoragePrefix) == 0 {
obj.KubernetesStoragePrefix = "kubernetes.io"
}
if len(obj.OpenShiftStorageVersion) == 0 {
obj.OpenShiftStorageVersion = "v1beta3"
}
if len(obj.OpenShiftStoragePrefix) == 0 {
obj.OpenShiftStoragePrefix = "openshift.io"
}
},
)
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.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.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)
}
}