Skip to content

Commit bd47007

Browse files
pranavsriram8l-technicore
authored andcommitted
Add validation if loadbalancer subnets are empty and add unit test cases for individual methods
1 parent 448366c commit bd47007

File tree

2 files changed

+371
-8
lines changed

2 files changed

+371
-8
lines changed

pkg/cloudprovider/providers/oci/load_balancer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -844,12 +844,12 @@ func (cp *CloudProvider) getOciLoadBalancerSubnets(ctx context.Context, logger *
844844
}
845845
}
846846

847+
if subnets[0] == "" || (len(subnets) == 2 && subnets[1] == "") {
848+
return nil, errors.Errorf("a subnet must be specified for creating a load balancer")
849+
}
847850
if internal {
848851
// Public load balancers need two subnets if they are AD specific and only first subnet is used if regional. Internal load
849852
// balancers will always use the first subnet.
850-
if subnets[0] == "" {
851-
return nil, errors.Errorf("a configuration for subnet1 must be specified for an internal load balancer")
852-
}
853853
return subnets[:1], nil
854854
}
855855

0 commit comments

Comments
 (0)