@@ -32,13 +32,13 @@ import (
3232)
3333
3434func (s * ClusterScope ) ReconcileSubnet (ctx context.Context ) error {
35- desiredSubnets := ptr . ToSubnetSlice ( s .OCIClusterAccessor .GetNetworkSpec ().Vcn .Subnets )
35+ desiredSubnets := s .OCIClusterAccessor .GetNetworkSpec ().Vcn .Subnets
3636 for _ , desiredSubnet := range desiredSubnets {
3737 if desiredSubnet .Skip {
3838 s .Logger .Info ("Skipping Subnet reconciliation as per spec" )
3939 continue
4040 }
41- subnet , err := s .GetSubnet (ctx , desiredSubnet )
41+ subnet , err := s .GetSubnet (ctx , * desiredSubnet )
4242 if err != nil {
4343 return err
4444 }
@@ -69,10 +69,10 @@ func (s *ClusterScope) ReconcileSubnet(ctx context.Context) error {
6969 }
7070 }
7171 }
72- if s .IsSubnetsEqual (subnet , desiredSubnet ) {
72+ if s .IsSubnetsEqual (subnet , * desiredSubnet ) {
7373 s .Logger .Info ("No Reconciliation Required for Subnet" , "subnet" , subnetOCID )
7474 } else {
75- err = s .UpdateSubnet (ctx , desiredSubnet )
75+ err = s .UpdateSubnet (ctx , * desiredSubnet )
7676 if err != nil {
7777 return err
7878 }
@@ -90,7 +90,7 @@ func (s *ClusterScope) ReconcileSubnet(ctx context.Context) error {
9090 s .Logger .Info ("Created the security list" , "ocid" , seclistId )
9191 desiredSubnet .SecurityList .ID = seclistId
9292 }
93- subnetId , err := s .CreateSubnet (ctx , desiredSubnet )
93+ subnetId , err := s .CreateSubnet (ctx , * desiredSubnet )
9494 if err != nil {
9595 return err
9696 }
@@ -197,13 +197,13 @@ func (s *ClusterScope) UpdateSubnet(ctx context.Context, spec infrastructurev1be
197197}
198198
199199func (s * ClusterScope ) DeleteSubnets (ctx context.Context ) error {
200- desiredSubnets := ptr . ToSubnetSlice ( s .GetSubnetsSpec () )
200+ desiredSubnets := s .GetSubnetsSpec ()
201201 for _ , desiredSubnet := range desiredSubnets {
202202 if desiredSubnet .Skip {
203203 s .Logger .Info ("Skipping Subnet reconciliation as per spec" )
204204 continue
205205 }
206- subnet , err := s .GetSubnet (ctx , desiredSubnet )
206+ subnet , err := s .GetSubnet (ctx , * desiredSubnet )
207207 if err != nil && ! ociutil .IsNotFound (err ) {
208208 return err
209209 }
@@ -325,7 +325,9 @@ func (s *ClusterScope) isControlPlaneEndpointSubnetPrivate() bool {
325325}
326326
327327func (s * ClusterScope ) GetControlPlaneEndpointSubnetCidr () string {
328- for _ , subnet := range ptr .ToSubnetSlice (s .GetSubnetsSpec ()) {
328+ subnetSlice := ptr .ToSubnetSlice (s .GetSubnetsSpec ())
329+ for i := range subnetSlice {
330+ subnet := & subnetSlice [i ]
329331 if subnet .Role == infrastructurev1beta2 .ControlPlaneEndpointRole {
330332 if subnet .CIDR != "" {
331333 return subnet .CIDR
@@ -336,7 +338,9 @@ func (s *ClusterScope) GetControlPlaneEndpointSubnetCidr() string {
336338}
337339
338340func (s * ClusterScope ) GetServiceLoadBalancerSubnetCidr () string {
339- for _ , subnet := range ptr .ToSubnetSlice (s .GetSubnetsSpec ()) {
341+ subnetSlice := ptr .ToSubnetSlice (s .GetSubnetsSpec ())
342+ for i := range subnetSlice {
343+ subnet := & subnetSlice [i ]
340344 if subnet .Role == infrastructurev1beta2 .ServiceLoadBalancerRole {
341345 if subnet .CIDR != "" {
342346 return subnet .CIDR
@@ -347,9 +351,10 @@ func (s *ClusterScope) GetServiceLoadBalancerSubnetCidr() string {
347351}
348352
349353func (s * ClusterScope ) NodeSubnetCidr () []string {
350- subnets := s .GetNodeSubnet ()
351354 var nodeCIDR []string
352- for _ , subnet := range ptr .ToSubnetSlice (subnets ) {
355+ subnetSlice := ptr .ToSubnetSlice (s .GetNodeSubnet ())
356+ for i := range subnetSlice {
357+ subnet := & subnetSlice [i ]
353358 if subnet .CIDR != "" {
354359 nodeCIDR = append (nodeCIDR , subnet .CIDR )
355360 }
@@ -372,7 +377,9 @@ func (s *ClusterScope) GetControlPlaneMachineSubnetCidr() string {
372377
373378// IsAllSubnetsPrivate determines if all the ClusterScope's subnets are private
374379func (s * ClusterScope ) IsAllSubnetsPrivate () bool {
375- for _ , subnet := range ptr .ToSubnetSlice (s .GetSubnetsSpec ()) {
380+ subnetSlice := ptr .ToSubnetSlice (s .GetSubnetsSpec ())
381+ for i := range subnetSlice {
382+ subnet := & subnetSlice [i ]
376383 if subnet .Type == infrastructurev1beta2 .Public {
377384 return false
378385 }
0 commit comments