Skip to content

Commit 64f49a4

Browse files
committed
simplified nil check
1 parent 3f65a65 commit 64f49a4

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

pkg/providers/v1/aws_loadbalancer.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,21 +1510,17 @@ func (c *Cloud) ensureSSLNegotiationPolicy(ctx context.Context, loadBalancer *el
15101510
fmt.Sprintf(SSLNegotiationPolicyNameFormat, policyName),
15111511
},
15121512
})
1513-
policyNotFoundError := false
15141513
if err != nil {
1514+
// If DescribeLoadBalancerPolicies returns a PolicyNotFoundException, we must proceed and create the policy.
15151515
var notFoundErr *elbtypes.PolicyNotFoundException
15161516
if !errors.As(err, &notFoundErr) {
15171517
return fmt.Errorf("error describing security policies on load balancer: %q", err)
15181518
}
1519-
policyNotFoundError = true
15201519
}
15211520

1522-
// If DescribeLoadBalancerPolicies returns a PolicyNotFoundException, we must proceed and create the policy.
1523-
//
1524-
// The result of DescribeLoadBalancerPolicies will be nil, so we should only check
1525-
// result.PolicyDescriptions if DescribeLoadBalancerPolicies did not yield an error.
1526-
if (!policyNotFoundError) && (result != nil && len(result.PolicyDescriptions) > 0) {
1527-
// if policynotfound, would return false
1521+
// If DescribeLoadBalancerPolicies yielded a PolicyNotFoundException, result will be nil,
1522+
// so we must check before dereferencing
1523+
if result != nil && len(result.PolicyDescriptions) > 0 {
15281524
return nil
15291525
}
15301526

0 commit comments

Comments
 (0)