@@ -131,6 +131,10 @@ func (s *ClusterScope) CreateVPC() (*vpcv1.VPC, error) {
131131
132132// DeleteVPC deletes IBM VPC associated with a VPC id.
133133func (s * ClusterScope ) DeleteVPC () error {
134+ if s .IBMVPCCluster .Status .VPC .ID == "" {
135+ return nil
136+ }
137+
134138 deleteVpcOptions := & vpcv1.DeleteVPCOptions {}
135139 deleteVpcOptions .SetID (s .IBMVPCCluster .Status .VPC .ID )
136140 _ , err := s .IBMVPCClient .DeleteVPC (deleteVpcOptions )
@@ -267,6 +271,10 @@ func (s *ClusterScope) ensureFIPUnique(fipName string) (*vpcv1.FloatingIP, error
267271
268272// DeleteFloatingIP deletes a Floating IP associated with floating ip id.
269273func (s * ClusterScope ) DeleteFloatingIP () error {
274+ if s .IBMVPCCluster .Status .VPCEndpoint .FIPID == nil {
275+ return nil
276+ }
277+
270278 if fipID := * s .IBMVPCCluster .Status .VPCEndpoint .FIPID ; fipID != "" {
271279 deleteFIPOption := & vpcv1.DeleteFloatingIPOptions {}
272280 deleteFIPOption .SetID (fipID )
@@ -410,6 +418,10 @@ func (s *ClusterScope) ensureSubnetUnique(subnetName string) (*vpcv1.Subnet, err
410418
411419// DeleteSubnet deletes a subnet associated with subnet id.
412420func (s * ClusterScope ) DeleteSubnet () error {
421+ if s .IBMVPCCluster .Status .Subnet .ID == nil {
422+ return nil
423+ }
424+
413425 subnetID := * s .IBMVPCCluster .Status .Subnet .ID
414426
415427 // Lists the subnet available and compare before deleting to avoid any failure(404) later
@@ -703,6 +715,10 @@ func (s *ClusterScope) SetLoadBalancerID(id *string) {
703715
704716// GetLoadBalancerID will get the id for the load balancer.
705717func (s * ClusterScope ) GetLoadBalancerID () string {
718+ if s .IBMVPCCluster .Status .VPCEndpoint .LBID == nil {
719+ return ""
720+ }
721+
706722 return * s .IBMVPCCluster .Status .VPCEndpoint .LBID
707723}
708724
0 commit comments