@@ -833,7 +833,7 @@ func (c *OCICluster) GetControlPlaneEndpointDefaultEgressRules() []EgressSecurit
833833
834834func (c * OCICluster ) GetControlPlaneEndpointSubnet () * Subnet {
835835 for _ , subnet := range c .Spec .NetworkSpec .Vcn .Subnets {
836- if subnet .Role == ControlPlaneEndpointRole {
836+ if subnet != nil && subnet .Role == ControlPlaneEndpointRole {
837837 return subnet
838838 }
839839 }
@@ -842,7 +842,7 @@ func (c *OCICluster) GetControlPlaneEndpointSubnet() *Subnet {
842842
843843func (c * OCICluster ) GetControlPlaneMachineSubnet () * Subnet {
844844 for _ , subnet := range c .Spec .NetworkSpec .Vcn .Subnets {
845- if subnet .Role == ControlPlaneRole {
845+ if subnet != nil && subnet .Role == ControlPlaneRole {
846846 return subnet
847847 }
848848 }
@@ -851,7 +851,7 @@ func (c *OCICluster) GetControlPlaneMachineSubnet() *Subnet {
851851
852852func (c * OCICluster ) GetServiceLoadBalancerSubnet () * Subnet {
853853 for _ , subnet := range c .Spec .NetworkSpec .Vcn .Subnets {
854- if subnet .Role == ServiceLoadBalancerRole {
854+ if subnet != nil && subnet .Role == ServiceLoadBalancerRole {
855855 return subnet
856856 }
857857 }
@@ -861,7 +861,7 @@ func (c *OCICluster) GetServiceLoadBalancerSubnet() *Subnet {
861861func (c * OCICluster ) GetNodeSubnet () []* Subnet {
862862 var nodeSubnets []* Subnet
863863 for _ , subnet := range c .Spec .NetworkSpec .Vcn .Subnets {
864- if subnet .Role == WorkerRole {
864+ if subnet != nil && subnet .Role == WorkerRole {
865865 nodeSubnets = append (nodeSubnets , subnet )
866866 }
867867 }
@@ -870,7 +870,7 @@ func (c *OCICluster) GetNodeSubnet() []*Subnet {
870870
871871func (c * OCICluster ) IsNSGExitsByRole (role Role ) bool {
872872 for _ , nsg := range c .Spec .NetworkSpec .Vcn .NetworkSecurityGroup .List {
873- if role == nsg .Role {
873+ if nsg != nil && role == nsg .Role {
874874 return true
875875 }
876876 }
@@ -879,7 +879,7 @@ func (c *OCICluster) IsNSGExitsByRole(role Role) bool {
879879
880880func (c * OCICluster ) IsSecurityListExitsByRole (role Role ) bool {
881881 for _ , subnet := range c .Spec .NetworkSpec .Vcn .Subnets {
882- if role == subnet .Role {
882+ if subnet != nil && role == subnet .Role {
883883 if subnet .SecurityList != nil {
884884 return true
885885 }
0 commit comments