forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
conversion.go
134 lines (120 loc) · 4.11 KB
/
conversion.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
package v1
import (
"reflect"
"strings"
"k8s.io/kubernetes/pkg/conversion"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util/intstr"
oapi "github.com/openshift/origin/pkg/api"
newer "github.com/openshift/origin/pkg/deploy/api"
imageapi "github.com/openshift/origin/pkg/image/api"
)
func Convert_v1_DeploymentTriggerImageChangeParams_To_api_DeploymentTriggerImageChangeParams(in *DeploymentTriggerImageChangeParams, out *newer.DeploymentTriggerImageChangeParams, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*DeploymentTriggerImageChangeParams))(in)
}
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
switch in.From.Kind {
case "ImageStreamTag":
case "ImageStream", "ImageRepository":
out.From.Kind = "ImageStreamTag"
if !strings.Contains(out.From.Name, ":") {
out.From.Name = imageapi.JoinImageStreamTag(out.From.Name, imageapi.DefaultImageTag)
}
default:
// Will be handled by validation
}
return nil
}
func Convert_api_DeploymentTriggerImageChangeParams_To_v1_DeploymentTriggerImageChangeParams(in *newer.DeploymentTriggerImageChangeParams, out *DeploymentTriggerImageChangeParams, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
switch in.From.Kind {
case "ImageStreamTag":
case "ImageStream", "ImageRepository":
out.From.Kind = "ImageStreamTag"
if !strings.Contains(out.From.Name, ":") {
out.From.Name = imageapi.JoinImageStreamTag(out.From.Name, imageapi.DefaultImageTag)
}
default:
// Will be handled by validation
}
return nil
}
func Convert_v1_RollingDeploymentStrategyParams_To_api_RollingDeploymentStrategyParams(in *RollingDeploymentStrategyParams, out *newer.RollingDeploymentStrategyParams, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*RollingDeploymentStrategyParams))(in)
}
out.UpdatePeriodSeconds = in.UpdatePeriodSeconds
out.IntervalSeconds = in.IntervalSeconds
out.TimeoutSeconds = in.TimeoutSeconds
if in.Pre != nil {
if err := s.Convert(&in.Pre, &out.Pre, 0); err != nil {
return err
}
}
if in.Post != nil {
if err := s.Convert(&in.Post, &out.Post, 0); err != nil {
return err
}
}
if in.MaxUnavailable != nil {
if err := s.Convert(in.MaxUnavailable, &out.MaxUnavailable, 0); err != nil {
return err
}
}
if in.MaxSurge != nil {
if err := s.Convert(in.MaxSurge, &out.MaxSurge, 0); err != nil {
return err
}
}
return nil
}
func Convert_api_RollingDeploymentStrategyParams_To_v1_RollingDeploymentStrategyParams(in *newer.RollingDeploymentStrategyParams, out *RollingDeploymentStrategyParams, s conversion.Scope) error {
out.UpdatePeriodSeconds = in.UpdatePeriodSeconds
out.IntervalSeconds = in.IntervalSeconds
out.TimeoutSeconds = in.TimeoutSeconds
if in.Pre != nil {
if err := s.Convert(&in.Pre, &out.Pre, 0); err != nil {
return err
}
}
if in.Post != nil {
if err := s.Convert(&in.Post, &out.Post, 0); err != nil {
return err
}
}
if out.MaxUnavailable == nil {
out.MaxUnavailable = &intstr.IntOrString{}
}
if out.MaxSurge == nil {
out.MaxSurge = &intstr.IntOrString{}
}
if err := s.Convert(&in.MaxUnavailable, out.MaxUnavailable, 0); err != nil {
return err
}
if err := s.Convert(&in.MaxSurge, out.MaxSurge, 0); err != nil {
return err
}
return nil
}
func addConversionFuncs(scheme *runtime.Scheme) error {
err := scheme.AddConversionFuncs(
Convert_v1_DeploymentTriggerImageChangeParams_To_api_DeploymentTriggerImageChangeParams,
Convert_api_DeploymentTriggerImageChangeParams_To_v1_DeploymentTriggerImageChangeParams,
Convert_v1_RollingDeploymentStrategyParams_To_api_RollingDeploymentStrategyParams,
Convert_api_RollingDeploymentStrategyParams_To_v1_RollingDeploymentStrategyParams,
)
if err != nil {
return err
}
if err := scheme.AddFieldLabelConversionFunc("v1", "DeploymentConfig",
oapi.GetFieldLabelConversionFunc(newer.DeploymentConfigToSelectableFields(&newer.DeploymentConfig{}), nil),
); err != nil {
return err
}
return nil
}