@@ -18,7 +18,6 @@ package v1alpha7
18
18
19
19
import (
20
20
apiconversion "k8s.io/apimachinery/pkg/conversion"
21
- "k8s.io/utils/pointer"
22
21
23
22
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
24
23
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/optional"
@@ -40,9 +39,7 @@ func restorev1alpha7SecurityGroup(previous *SecurityGroup, dst *SecurityGroup) {
40
39
return
41
40
}
42
41
43
- for i , rule := range previous .Rules {
44
- dst .Rules [i ].SecurityGroupID = rule .SecurityGroupID
45
- }
42
+ dst .Rules = previous .Rules
46
43
}
47
44
48
45
func Convert_v1alpha7_SecurityGroupFilter_To_v1beta1_SecurityGroupFilter (in * SecurityGroupFilter , out * infrav1.SecurityGroupFilter , s apiconversion.Scope ) error {
@@ -142,39 +139,6 @@ func Convert_v1beta1_RouterFilter_To_v1alpha7_RouterFilter(in *infrav1.RouterFil
142
139
return nil
143
140
}
144
141
145
- func restorev1beta1SecurityGroupStatus (previous * infrav1.SecurityGroupStatus , dst * infrav1.SecurityGroupStatus ) {
146
- if previous == nil || dst == nil {
147
- return
148
- }
149
-
150
- for i := range dst .Rules {
151
- dstRule := & dst .Rules [i ]
152
-
153
- // Conversion from scalar to *scalar is lossy for zero values. We need to restore only nil values.
154
- if dstRule .Description != nil && * dstRule .Description == "" {
155
- dstRule .Description = previous .Rules [i ].Description
156
- }
157
- if dstRule .EtherType != nil && * dstRule .EtherType == "" {
158
- dstRule .EtherType = previous .Rules [i ].EtherType
159
- }
160
- if dstRule .PortRangeMin != nil && * dstRule .PortRangeMin == 0 {
161
- dstRule .PortRangeMin = previous .Rules [i ].PortRangeMin
162
- }
163
- if dstRule .PortRangeMax != nil && * dstRule .PortRangeMax == 0 {
164
- dstRule .PortRangeMax = previous .Rules [i ].PortRangeMax
165
- }
166
- if dstRule .Protocol != nil && * dstRule .Protocol == "" {
167
- dstRule .Protocol = previous .Rules [i ].Protocol
168
- }
169
- if dstRule .RemoteGroupID != nil && * dstRule .RemoteGroupID == "" {
170
- dstRule .RemoteGroupID = previous .Rules [i ].RemoteGroupID
171
- }
172
- if dstRule .RemoteIPPrefix != nil && * dstRule .RemoteIPPrefix == "" {
173
- dstRule .RemoteIPPrefix = previous .Rules [i ].RemoteIPPrefix
174
- }
175
- }
176
- }
177
-
178
142
/* PortOpts */
179
143
180
144
func restorev1alpha7Port (previous * PortOpts , dst * PortOpts ) {
@@ -300,55 +264,13 @@ func Convert_v1beta1_PortOpts_To_v1alpha7_PortOpts(in *infrav1.PortOpts, out *Po
300
264
func Convert_v1alpha7_SecurityGroup_To_v1beta1_SecurityGroupStatus (in * SecurityGroup , out * infrav1.SecurityGroupStatus , _ apiconversion.Scope ) error {
301
265
out .ID = in .ID
302
266
out .Name = in .Name
303
- out .Rules = make ([]infrav1.SecurityGroupRuleStatus , len (in .Rules ))
304
- for i , rule := range in .Rules {
305
- out .Rules [i ] = infrav1.SecurityGroupRuleStatus {
306
- ID : rule .ID ,
307
- Description : pointer .String (rule .Description ),
308
- Direction : rule .Direction ,
309
- EtherType : pointer .String (rule .EtherType ),
310
- PortRangeMin : pointer .Int (rule .PortRangeMin ),
311
- PortRangeMax : pointer .Int (rule .PortRangeMax ),
312
- Protocol : pointer .String (rule .Protocol ),
313
- RemoteGroupID : pointer .String (rule .RemoteGroupID ),
314
- RemoteIPPrefix : pointer .String (rule .RemoteIPPrefix ),
315
- }
316
- }
317
267
318
268
return nil
319
269
}
320
270
321
271
func Convert_v1beta1_SecurityGroupStatus_To_v1alpha7_SecurityGroup (in * infrav1.SecurityGroupStatus , out * SecurityGroup , _ apiconversion.Scope ) error {
322
272
out .ID = in .ID
323
273
out .Name = in .Name
324
- out .Rules = make ([]SecurityGroupRule , len (in .Rules ))
325
- for i , rule := range in .Rules {
326
- out .Rules [i ] = SecurityGroupRule {
327
- ID : rule .ID ,
328
- Direction : rule .Direction ,
329
- }
330
- if rule .Description != nil {
331
- out .Rules [i ].Description = * rule .Description
332
- }
333
- if rule .EtherType != nil {
334
- out .Rules [i ].EtherType = * rule .EtherType
335
- }
336
- if rule .PortRangeMin != nil {
337
- out .Rules [i ].PortRangeMin = * rule .PortRangeMin
338
- }
339
- if rule .PortRangeMax != nil {
340
- out .Rules [i ].PortRangeMax = * rule .PortRangeMax
341
- }
342
- if rule .Protocol != nil {
343
- out .Rules [i ].Protocol = * rule .Protocol
344
- }
345
- if rule .RemoteGroupID != nil {
346
- out .Rules [i ].RemoteGroupID = * rule .RemoteGroupID
347
- }
348
- if rule .RemoteIPPrefix != nil {
349
- out .Rules [i ].RemoteIPPrefix = * rule .RemoteIPPrefix
350
- }
351
- }
352
274
return nil
353
275
}
354
276
0 commit comments