@@ -272,11 +272,29 @@ func Convert_v1beta1_PortOpts_To_v1alpha5_PortOpts(in *infrav1.PortOpts, out *Po
272
272
return err
273
273
}
274
274
275
+ // The auto-generated function converts v1beta1 SecurityGroup to
276
+ // v1alpha6 SecurityGroup, but v1alpha6 SecurityGroupFilter is more
277
+ // appropriate. Unset them and convert to SecurityGroupFilter instead.
278
+ out .SecurityGroups = nil
279
+ if len (in .SecurityGroups ) > 0 {
280
+ out .SecurityGroupFilters = make ([]SecurityGroupParam , len (in .SecurityGroups ))
281
+ for i := range in .SecurityGroups {
282
+ securityGroupParam := & out .SecurityGroupFilters [i ]
283
+ if in .SecurityGroups [i ].ID != "" {
284
+ securityGroupParam .UUID = in .SecurityGroups [i ].ID
285
+ } else {
286
+ if err := Convert_v1beta1_SecurityGroupFilter_To_v1alpha5_SecurityGroupFilter (& in .SecurityGroups [i ], & securityGroupParam .Filter , s ); err != nil {
287
+ return err
288
+ }
289
+ }
290
+ }
291
+ }
292
+
275
293
out .Profile = make (map [string ]string )
276
- if in .Profile .OVSHWOffload {
294
+ if pointer . BoolDeref ( in .Profile .OVSHWOffload , false ) {
277
295
(out .Profile )["capabilities" ] = "[\" switchdev\" ]"
278
296
}
279
- if in .Profile .TrustedVF {
297
+ if pointer . BoolDeref ( in .Profile .TrustedVF , false ) {
280
298
(out .Profile )["trusted" ] = trueString
281
299
}
282
300
return nil
@@ -318,12 +336,56 @@ func Convert_v1alpha5_PortOpts_To_v1beta1_PortOpts(in *PortOpts, out *infrav1.Po
318
336
return err
319
337
}
320
338
339
+ if len (in .SecurityGroups ) > 0 || len (in .SecurityGroupFilters ) > 0 {
340
+ out .SecurityGroups = make ([]infrav1.SecurityGroupFilter , 0 , len (in .SecurityGroups )+ len (in .SecurityGroupFilters ))
341
+ for i := range in .SecurityGroupFilters {
342
+ sgParam := & in .SecurityGroupFilters [i ]
343
+ switch {
344
+ case sgParam .UUID != "" :
345
+ out .SecurityGroups = append (out .SecurityGroups , infrav1.SecurityGroupFilter {ID : sgParam .UUID })
346
+ case sgParam .Name != "" :
347
+ out .SecurityGroups = append (out .SecurityGroups , infrav1.SecurityGroupFilter {Name : sgParam .Name })
348
+ case sgParam .Filter != (SecurityGroupFilter {}):
349
+ out .SecurityGroups = append (out .SecurityGroups , infrav1.SecurityGroupFilter {})
350
+ outSG := & out .SecurityGroups [len (out .SecurityGroups )- 1 ]
351
+ if err := Convert_v1alpha5_SecurityGroupFilter_To_v1beta1_SecurityGroupFilter (& sgParam .Filter , outSG , s ); err != nil {
352
+ return err
353
+ }
354
+ }
355
+ }
356
+ for _ , id := range in .SecurityGroups {
357
+ out .SecurityGroups = append (out .SecurityGroups , infrav1.SecurityGroupFilter {ID : id })
358
+ }
359
+ }
360
+
361
+ if len (in .SecurityGroups ) > 0 || len (in .SecurityGroupFilters ) > 0 {
362
+ out .SecurityGroups = make ([]infrav1.SecurityGroupFilter , 0 , len (in .SecurityGroups )+ len (in .SecurityGroupFilters ))
363
+ for i := range in .SecurityGroupFilters {
364
+ sgParam := & in .SecurityGroupFilters [i ]
365
+ switch {
366
+ case sgParam .UUID != "" :
367
+ out .SecurityGroups = append (out .SecurityGroups , infrav1.SecurityGroupFilter {ID : sgParam .UUID })
368
+ case sgParam .Name != "" :
369
+ out .SecurityGroups = append (out .SecurityGroups , infrav1.SecurityGroupFilter {Name : sgParam .Name })
370
+ case sgParam .Filter != (SecurityGroupFilter {}):
371
+ out .SecurityGroups = append (out .SecurityGroups , infrav1.SecurityGroupFilter {})
372
+ outSG := & out .SecurityGroups [len (out .SecurityGroups )- 1 ]
373
+ if err := Convert_v1alpha5_SecurityGroupFilter_To_v1beta1_SecurityGroupFilter (& sgParam .Filter , outSG , s ); err != nil {
374
+ return err
375
+ }
376
+ }
377
+ }
378
+ for _ , id := range in .SecurityGroups {
379
+ out .SecurityGroups = append (out .SecurityGroups , infrav1.SecurityGroupFilter {ID : id })
380
+ }
381
+ }
382
+
321
383
// Profile is now a struct in v1beta1.
322
384
if strings .Contains (in .Profile ["capabilities" ], "switchdev" ) {
323
- out .Profile .OVSHWOffload = true
385
+ out .Profile .OVSHWOffload = pointer . Bool ( true )
324
386
}
325
387
if in .Profile ["trusted" ] == trueString {
326
- out .Profile .TrustedVF = true
388
+ out .Profile .TrustedVF = pointer . Bool ( true )
327
389
}
328
390
return nil
329
391
}
@@ -460,21 +522,21 @@ func Convert_Map_string_To_Interface_To_v1beta1_BindingProfile(in map[string]str
460
522
for k , v := range in {
461
523
if k == "capabilities" {
462
524
if strings .Contains (v , "switchdev" ) {
463
- out .OVSHWOffload = true
525
+ out .OVSHWOffload = pointer . Bool ( true )
464
526
}
465
527
}
466
528
if k == "trusted" && v == trueString {
467
- out .TrustedVF = true
529
+ out .TrustedVF = pointer . Bool ( true )
468
530
}
469
531
}
470
532
return nil
471
533
}
472
534
473
535
func Convert_v1beta1_BindingProfile_To_Map_string_To_Interface (in * infrav1.BindingProfile , out map [string ]string , _ conversion.Scope ) error {
474
- if in .OVSHWOffload {
536
+ if pointer . BoolDeref ( in .OVSHWOffload , false ) {
475
537
(out )["capabilities" ] = "[\" switchdev\" ]"
476
538
}
477
- if in .TrustedVF {
539
+ if pointer . BoolDeref ( in .TrustedVF , false ) {
478
540
(out )["trusted" ] = trueString
479
541
}
480
542
return nil
0 commit comments