@@ -268,7 +268,7 @@ func (r *ROSAControlPlaneReconciler) reconcileNormal(ctx context.Context, rosaSc
268268 billingAccount = rosaScope .ControlPlane .Spec .BillingAccount
269269 }
270270
271- spec := ocm.Spec {
271+ ocmClusterSpec := ocm.Spec {
272272 DryRun : ptr .To (false ),
273273 Name : rosaScope .RosaClusterName (),
274274 Region : * rosaScope .ControlPlane .Spec .Region ,
@@ -282,7 +282,6 @@ func (r *ROSAControlPlaneReconciler) reconcileNormal(ctx context.Context, rosaSc
282282
283283 SubnetIds : rosaScope .ControlPlane .Spec .Subnets ,
284284 AvailabilityZones : rosaScope .ControlPlane .Spec .AvailabilityZones ,
285- NetworkType : rosaScope .ControlPlane .Spec .Network .NetworkType ,
286285 IsSTS : true ,
287286 RoleARN : * rosaScope .ControlPlane .Spec .InstallerRoleARN ,
288287 SupportRoleARN : * rosaScope .ControlPlane .Spec .SupportRoleARN ,
@@ -297,44 +296,48 @@ func (r *ROSAControlPlaneReconciler) reconcileNormal(ctx context.Context, rosaSc
297296 AWSCreator : creator ,
298297 }
299298
300- _ , machineCIDR , err := net .ParseCIDR (rosaScope .ControlPlane .Spec .Network .MachineCIDR )
301- if err == nil {
302- spec .MachineCIDR = * machineCIDR
303- } else {
304- // TODO: expose in status
305- rosaScope .Error (err , "rosacontrolplane.spec.network.machineCIDR invalid" , rosaScope .ControlPlane .Spec .Network .MachineCIDR )
306- return ctrl.Result {}, nil
307- }
299+ if networkSpec := rosaScope .ControlPlane .Spec .Network ; networkSpec != nil {
300+ if networkSpec .MachineCIDR != "" {
301+ _ , machineCIDR , err := net .ParseCIDR (networkSpec .MachineCIDR )
302+ if err != nil {
303+ // TODO: expose in status
304+ rosaScope .Error (err , "rosacontrolplane.spec.network.machineCIDR invalid" , networkSpec .MachineCIDR )
305+ return ctrl.Result {}, nil
306+ }
307+ ocmClusterSpec .MachineCIDR = * machineCIDR
308+ }
308309
309- if rosaScope . ControlPlane . Spec . Network .PodCIDR != "" {
310- _ , podCIDR , err := net .ParseCIDR (rosaScope . ControlPlane . Spec . Network .PodCIDR )
311- if err = = nil {
312- spec . PodCIDR = * podCIDR
313- } else {
314- // TODO: expose in status.
315- rosaScope . Error ( err , "rosacontrolplane.spec.network.podCIDR invalid" , rosaScope . ControlPlane . Spec . Network . PodCIDR )
316- return ctrl. Result {}, nil
310+ if networkSpec .PodCIDR != "" {
311+ _ , podCIDR , err := net .ParseCIDR (networkSpec .PodCIDR )
312+ if err ! = nil {
313+ // TODO: expose in status.
314+ rosaScope . Error ( err , "rosacontrolplane.spec.network.podCIDR invalid" , networkSpec . PodCIDR )
315+ return ctrl. Result {}, nil
316+ }
317+ ocmClusterSpec . PodCIDR = * podCIDR
317318 }
318- }
319319
320- if rosaScope . ControlPlane . Spec . Network .ServiceCIDR != "" {
321- _ , serviceCIDR , err := net .ParseCIDR (rosaScope . ControlPlane . Spec . Network .ServiceCIDR )
322- if err = = nil {
323- spec . ServiceCIDR = * serviceCIDR
324- } else {
325- // TODO: expose in status.
326- rosaScope . Error ( err , "rosacontrolplane.spec.network.serviceCIDR invalid" , rosaScope . ControlPlane . Spec . Network . ServiceCIDR )
327- return ctrl. Result {}, nil
320+ if networkSpec .ServiceCIDR != "" {
321+ _ , serviceCIDR , err := net .ParseCIDR (networkSpec .ServiceCIDR )
322+ if err ! = nil {
323+ // TODO: expose in status.
324+ rosaScope . Error ( err , "rosacontrolplane.spec.network.serviceCIDR invalid" , networkSpec . ServiceCIDR )
325+ return ctrl. Result {}, nil
326+ }
327+ ocmClusterSpec . ServiceCIDR = * serviceCIDR
328328 }
329+
330+ ocmClusterSpec .HostPrefix = networkSpec .HostPrefix
331+ ocmClusterSpec .NetworkType = networkSpec .NetworkType
329332 }
330333
331334 // Set autoscale replica
332335 if rosaScope .ControlPlane .Spec .Autoscaling != nil {
333- spec .MaxReplicas = rosaScope .ControlPlane .Spec .Autoscaling .MaxReplicas
334- spec .MinReplicas = rosaScope .ControlPlane .Spec .Autoscaling .MinReplicas
336+ ocmClusterSpec .MaxReplicas = rosaScope .ControlPlane .Spec .Autoscaling .MaxReplicas
337+ ocmClusterSpec .MinReplicas = rosaScope .ControlPlane .Spec .Autoscaling .MinReplicas
335338 }
336339
337- cluster , err = ocmClient .CreateCluster (spec )
340+ cluster , err = ocmClient .CreateCluster (ocmClusterSpec )
338341 if err != nil {
339342 // TODO: need to expose in status, as likely the spec is invalid
340343 return ctrl.Result {}, fmt .Errorf ("failed to create OCM cluster: %w" , err )
0 commit comments