@@ -131,6 +131,10 @@ func (s *ClusterScope) CreateVPC() (*vpcv1.VPC, error) {
131
131
132
132
// DeleteVPC deletes IBM VPC associated with a VPC id.
133
133
func (s * ClusterScope ) DeleteVPC () error {
134
+ if s .IBMVPCCluster .Status .VPC .ID == "" {
135
+ return nil
136
+ }
137
+
134
138
deleteVpcOptions := & vpcv1.DeleteVPCOptions {}
135
139
deleteVpcOptions .SetID (s .IBMVPCCluster .Status .VPC .ID )
136
140
_ , err := s .IBMVPCClient .DeleteVPC (deleteVpcOptions )
@@ -267,6 +271,10 @@ func (s *ClusterScope) ensureFIPUnique(fipName string) (*vpcv1.FloatingIP, error
267
271
268
272
// DeleteFloatingIP deletes a Floating IP associated with floating ip id.
269
273
func (s * ClusterScope ) DeleteFloatingIP () error {
274
+ if s .IBMVPCCluster .Status .VPCEndpoint .FIPID == nil {
275
+ return nil
276
+ }
277
+
270
278
if fipID := * s .IBMVPCCluster .Status .VPCEndpoint .FIPID ; fipID != "" {
271
279
deleteFIPOption := & vpcv1.DeleteFloatingIPOptions {}
272
280
deleteFIPOption .SetID (fipID )
@@ -410,6 +418,10 @@ func (s *ClusterScope) ensureSubnetUnique(subnetName string) (*vpcv1.Subnet, err
410
418
411
419
// DeleteSubnet deletes a subnet associated with subnet id.
412
420
func (s * ClusterScope ) DeleteSubnet () error {
421
+ if s .IBMVPCCluster .Status .Subnet .ID == nil {
422
+ return nil
423
+ }
424
+
413
425
subnetID := * s .IBMVPCCluster .Status .Subnet .ID
414
426
415
427
// Lists the subnet available and compare before deleting to avoid any failure(404) later
@@ -703,6 +715,10 @@ func (s *ClusterScope) SetLoadBalancerID(id *string) {
703
715
704
716
// GetLoadBalancerID will get the id for the load balancer.
705
717
func (s * ClusterScope ) GetLoadBalancerID () string {
718
+ if s .IBMVPCCluster .Status .VPCEndpoint .LBID == nil {
719
+ return ""
720
+ }
721
+
706
722
return * s .IBMVPCCluster .Status .VPCEndpoint .LBID
707
723
}
708
724
0 commit comments