Skip to content

Commit ab80151

Browse files
committed
fixup! fixup! fixup! fixup! fixup! ♻️ refacto: switch to SDKv3
1 parent b469ea6 commit ab80151

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

cloud-controller-manager/osc/cloud/loadbalancer.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,8 +1065,7 @@ func (c *Cloud) updateIngressSecurityGroupRules(ctx context.Context, l *LoadBala
10651065
var addRanges []string
10661066
for _, allowFrom := range allowed {
10671067
if !slices.ContainsFunc(lbSG.InboundRules, func(r osc.SecurityGroupRule) bool {
1068-
return r.FromPortRange == listener.Port && r.IpRanges != nil &&
1069-
slices.Contains(r.IpRanges, allowFrom)
1068+
return r.FromPortRange == listener.Port && slices.Contains(r.IpRanges, allowFrom)
10701069
}) {
10711070
addRanges = append(addRanges, allowFrom)
10721071
}
@@ -1105,7 +1104,7 @@ func (c *Cloud) updateIngressSecurityGroupRules(ctx context.Context, l *LoadBala
11051104
}
11061105
if del {
11071106
delRule.IpRanges = r.IpRanges
1108-
} else if r.IpRanges != nil {
1107+
} else if len(r.IpRanges) > 0 {
11091108
delRule.IpRanges = []string{}
11101109
for _, ipRange := range r.IpRanges {
11111110
if !slices.Contains(allowed, ipRange) {
@@ -1137,7 +1136,7 @@ func (c *Cloud) updateBackendSecurityGroupRules(ctx context.Context, l *LoadBala
11371136
// Adding new rules
11381137
for _, listener := range l.Listeners {
11391138
if slices.ContainsFunc(destSG.InboundRules, func(r osc.SecurityGroupRule) bool {
1140-
return r.FromPortRange == listener.BackendPort && r.SecurityGroupsMembers != nil &&
1139+
return r.FromPortRange == listener.BackendPort &&
11411140
slices.ContainsFunc(r.SecurityGroupsMembers, func(m osc.SecurityGroupsMember) bool {
11421141
return srcSGID == m.SecurityGroupId
11431142
})
@@ -1165,10 +1164,9 @@ func (c *Cloud) updateBackendSecurityGroupRules(ctx context.Context, l *LoadBala
11651164
// Removing rules
11661165
for _, r := range destSG.InboundRules {
11671166
// ignore if rule is not from the LB SG
1168-
if r.SecurityGroupsMembers == nil ||
1169-
!slices.ContainsFunc(r.SecurityGroupsMembers, func(m osc.SecurityGroupsMember) bool {
1170-
return m.SecurityGroupId == srcSGID
1171-
}) {
1167+
if !slices.ContainsFunc(r.SecurityGroupsMembers, func(m osc.SecurityGroupsMember) bool {
1168+
return m.SecurityGroupId == srcSGID
1169+
}) {
11721170
continue
11731171
}
11741172
// ignore if port is not from a lister

0 commit comments

Comments
 (0)