@@ -330,11 +330,94 @@ func restorev1alpha6Port(previous *PortOpts, dst *PortOpts) {
330
330
}
331
331
}
332
332
333
+ func restorev1beta1Port (previous * infrav1.PortOpts , dst * infrav1.PortOpts ) {
334
+ // PropagateUplinkStatus was not present in v1alpha6
335
+ dst .PropagateUplinkStatus = previous .PropagateUplinkStatus
336
+
337
+ optional .RestoreString (& previous .NameSuffix , & dst .NameSuffix )
338
+ optional .RestoreString (& previous .Description , & dst .Description )
339
+ optional .RestoreString (& previous .MACAddress , & dst .MACAddress )
340
+
341
+ if len (dst .FixedIPs ) == len (previous .FixedIPs ) {
342
+ for j := range dst .FixedIPs {
343
+ prevFixedIP := & previous .FixedIPs [j ]
344
+ dstFixedIP := & dst .FixedIPs [j ]
345
+
346
+ optional .RestoreString (& prevFixedIP .IPAddress , & dstFixedIP .IPAddress )
347
+ restorev1beta1SubnetParam (prevFixedIP .Subnet , dstFixedIP .Subnet )
348
+ }
349
+ }
350
+
351
+ if len (dst .AllowedAddressPairs ) == len (previous .AllowedAddressPairs ) {
352
+ for j := range dst .AllowedAddressPairs {
353
+ prevAAP := & previous .AllowedAddressPairs [j ]
354
+ dstAAP := & dst .AllowedAddressPairs [j ]
355
+
356
+ optional .RestoreString (& prevAAP .MACAddress , & dstAAP .MACAddress )
357
+ }
358
+ }
359
+
360
+ optional .RestoreString (& previous .HostID , & dst .HostID )
361
+ optional .RestoreString (& previous .VNICType , & dst .VNICType )
362
+
363
+ if previous .Profile != nil {
364
+ // A binding profile of {&false, &false} will be converted to a nil map.
365
+ // We still need to restore it, so substitute an empty BindProfile.
366
+ var dstProfile * infrav1.BindingProfile
367
+ if dst .Profile != nil {
368
+ dstProfile = dst .Profile
369
+ } else {
370
+ dstProfile = & infrav1.BindingProfile {}
371
+ dst .Profile = dstProfile
372
+ }
373
+ prevProfile := previous .Profile
374
+
375
+ if dstProfile .OVSHWOffload == nil || ! * dstProfile .OVSHWOffload {
376
+ dstProfile .OVSHWOffload = prevProfile .OVSHWOffload
377
+ }
378
+
379
+ if dstProfile .TrustedVF == nil || ! * dstProfile .TrustedVF {
380
+ dstProfile .TrustedVF = prevProfile .TrustedVF
381
+ }
382
+ }
383
+ }
384
+
333
385
func Convert_v1alpha6_PortOpts_To_v1beta1_PortOpts (in * PortOpts , out * infrav1.PortOpts , s apiconversion.Scope ) error {
334
386
if err := autoConvert_v1alpha6_PortOpts_To_v1beta1_PortOpts (in , out , s ); err != nil {
335
387
return err
336
388
}
337
389
390
+ // Copy members of ResolvedPortSpecFields
391
+ var allowedAddressPairs []infrav1.AddressPair
392
+ if len (in .AllowedAddressPairs ) > 0 {
393
+ allowedAddressPairs = make ([]infrav1.AddressPair , len (in .AllowedAddressPairs ))
394
+ for i := range in .AllowedAddressPairs {
395
+ aap := & in .AllowedAddressPairs [i ]
396
+ allowedAddressPairs [i ] = infrav1.AddressPair {
397
+ MACAddress : & aap .MACAddress ,
398
+ IPAddress : aap .IPAddress ,
399
+ }
400
+ }
401
+ }
402
+ var valueSpecs []infrav1.ValueSpec
403
+ if len (in .ValueSpecs ) > 0 {
404
+ valueSpecs = make ([]infrav1.ValueSpec , len (in .ValueSpecs ))
405
+ for i , vs := range in .ValueSpecs {
406
+ valueSpecs [i ] = infrav1 .ValueSpec (vs )
407
+ }
408
+ }
409
+ out .AdminStateUp = in .AdminStateUp
410
+ out .AllowedAddressPairs = allowedAddressPairs
411
+ out .DisablePortSecurity = in .DisablePortSecurity
412
+ out .ValueSpecs = valueSpecs
413
+ if err := errors .Join (
414
+ optional .Convert_string_To_optional_String (& in .MACAddress , & out .MACAddress , s ),
415
+ optional .Convert_string_To_optional_String (& in .HostID , & out .HostID , s ),
416
+ optional .Convert_string_To_optional_String (& in .VNICType , & out .VNICType , s ),
417
+ ); err != nil {
418
+ return err
419
+ }
420
+
338
421
if len (in .SecurityGroups ) > 0 || len (in .SecurityGroupFilters ) > 0 {
339
422
out .SecurityGroups = make ([]infrav1.SecurityGroupParam , len (in .SecurityGroups )+ len (in .SecurityGroupFilters ))
340
423
for i := range in .SecurityGroupFilters {
@@ -373,6 +456,38 @@ func Convert_v1beta1_PortOpts_To_v1alpha6_PortOpts(in *infrav1.PortOpts, out *Po
373
456
return err
374
457
}
375
458
459
+ // Copy members of ResolvedPortSpecFields
460
+ var allowedAddressPairs []AddressPair
461
+ if len (in .AllowedAddressPairs ) > 0 {
462
+ allowedAddressPairs = make ([]AddressPair , len (in .AllowedAddressPairs ))
463
+ for i := range in .AllowedAddressPairs {
464
+ inAAP := & in .AllowedAddressPairs [i ]
465
+ outAAP := & allowedAddressPairs [i ]
466
+ if err := optional .Convert_optional_String_To_string (& inAAP .MACAddress , & outAAP .MACAddress , s ); err != nil {
467
+ return err
468
+ }
469
+ outAAP .IPAddress = inAAP .IPAddress
470
+ }
471
+ }
472
+ var valueSpecs []ValueSpec
473
+ if len (in .ValueSpecs ) > 0 {
474
+ valueSpecs = make ([]ValueSpec , len (in .ValueSpecs ))
475
+ for i , vs := range in .ValueSpecs {
476
+ valueSpecs [i ] = ValueSpec (vs )
477
+ }
478
+ }
479
+ out .AdminStateUp = in .AdminStateUp
480
+ out .AllowedAddressPairs = allowedAddressPairs
481
+ out .DisablePortSecurity = in .DisablePortSecurity
482
+ out .ValueSpecs = valueSpecs
483
+ if err := errors .Join (
484
+ optional .Convert_optional_String_To_string (& in .MACAddress , & out .MACAddress , s ),
485
+ optional .Convert_optional_String_To_string (& in .HostID , & out .HostID , s ),
486
+ optional .Convert_optional_String_To_string (& in .VNICType , & out .VNICType , s ),
487
+ ); err != nil {
488
+ return err
489
+ }
490
+
376
491
// The auto-generated function converts v1beta1 SecurityGroup to
377
492
// v1alpha6 SecurityGroup, but v1alpha6 SecurityGroupFilter is more
378
493
// appropriate. Unset them and convert to SecurityGroupFilter instead.
0 commit comments