Skip to content

Commit

Permalink
verify if ID is present in Status before returning it to avoid nil po…
Browse files Browse the repository at this point in the history
…inter issue
  • Loading branch information
Amulyam24 committed Apr 19, 2024
1 parent 910b331 commit 0cf502c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cloud/scope/powervs_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func (s *PowerVSClusterScope) GetDHCPServerID() *string {
if s.IBMPowerVSCluster.Spec.DHCPServer != nil && s.IBMPowerVSCluster.Spec.DHCPServer.ID != nil {
return s.IBMPowerVSCluster.Spec.DHCPServer.ID
}
if s.IBMPowerVSCluster.Status.DHCPServer != nil {
if s.IBMPowerVSCluster.Status.DHCPServer != nil && s.IBMPowerVSCluster.Status.DHCPServer.ID != nil {
return s.IBMPowerVSCluster.Status.DHCPServer.ID
}
return nil
Expand All @@ -420,7 +420,7 @@ func (s *PowerVSClusterScope) GetVPCID() *string {
if s.IBMPowerVSCluster.Spec.VPC != nil && s.IBMPowerVSCluster.Spec.VPC.ID != nil {
return s.IBMPowerVSCluster.Spec.VPC.ID
}
if s.IBMPowerVSCluster.Status.VPC != nil {
if s.IBMPowerVSCluster.Status.VPC != nil && s.IBMPowerVSCluster.Status.VPC.ID != nil {
return s.IBMPowerVSCluster.Status.VPC.ID
}
return nil
Expand Down Expand Up @@ -482,7 +482,7 @@ func (s *PowerVSClusterScope) GetTransitGatewayID() *string {
if s.IBMPowerVSCluster.Spec.TransitGateway != nil && s.IBMPowerVSCluster.Spec.TransitGateway.ID != nil {
return s.IBMPowerVSCluster.Spec.TransitGateway.ID
}
if s.IBMPowerVSCluster.Status.TransitGateway != nil {
if s.IBMPowerVSCluster.Status.TransitGateway != nil && s.IBMPowerVSCluster.Status.TransitGateway.ID != nil {
return s.IBMPowerVSCluster.Status.TransitGateway.ID
}
return nil
Expand Down

0 comments on commit 0cf502c

Please sign in to comment.