@@ -272,11 +272,29 @@ func Convert_v1beta1_PortOpts_To_v1alpha5_PortOpts(in *infrav1.PortOpts, out *Po
272272 return err
273273 }
274274
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+
275293 out .Profile = make (map [string ]string )
276- if in .Profile .OVSHWOffload {
294+ if pointer . BoolDeref ( in .Profile .OVSHWOffload , false ) {
277295 (out .Profile )["capabilities" ] = "[\" switchdev\" ]"
278296 }
279- if in .Profile .TrustedVF {
297+ if pointer . BoolDeref ( in .Profile .TrustedVF , false ) {
280298 (out .Profile )["trusted" ] = trueString
281299 }
282300 return nil
@@ -318,12 +336,56 @@ func Convert_v1alpha5_PortOpts_To_v1beta1_PortOpts(in *PortOpts, out *infrav1.Po
318336 return err
319337 }
320338
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+
321383 // Profile is now a struct in v1beta1.
322384 if strings .Contains (in .Profile ["capabilities" ], "switchdev" ) {
323- out .Profile .OVSHWOffload = true
385+ out .Profile .OVSHWOffload = pointer . Bool ( true )
324386 }
325387 if in .Profile ["trusted" ] == trueString {
326- out .Profile .TrustedVF = true
388+ out .Profile .TrustedVF = pointer . Bool ( true )
327389 }
328390 return nil
329391}
@@ -460,21 +522,21 @@ func Convert_Map_string_To_Interface_To_v1beta1_BindingProfile(in map[string]str
460522 for k , v := range in {
461523 if k == "capabilities" {
462524 if strings .Contains (v , "switchdev" ) {
463- out .OVSHWOffload = true
525+ out .OVSHWOffload = pointer . Bool ( true )
464526 }
465527 }
466528 if k == "trusted" && v == trueString {
467- out .TrustedVF = true
529+ out .TrustedVF = pointer . Bool ( true )
468530 }
469531 }
470532 return nil
471533}
472534
473535func 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 ) {
475537 (out )["capabilities" ] = "[\" switchdev\" ]"
476538 }
477- if in .TrustedVF {
539+ if pointer . BoolDeref ( in .TrustedVF , false ) {
478540 (out )["trusted" ] = trueString
479541 }
480542 return nil
0 commit comments