Skip to content

Commit 289170c

Browse files
committed
use slices.Equal for subnet comparison
Signed-off-by: Mikkel Oscar Lyderik Larsen <[email protected]>
1 parent bcc95ba commit 289170c

File tree

3 files changed

+7
-23
lines changed

3 files changed

+7
-23
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ require (
1313
github.com/sirupsen/logrus v1.9.0
1414
github.com/stretchr/testify v1.8.4
1515
github.com/zalando/skipper v0.16.6
16+
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1
1617
gopkg.in/alecthomas/kingpin.v2 v2.2.6
1718
k8s.io/api v0.22.17
1819
k8s.io/apimachinery v0.22.17

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
389389
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
390390
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
391391
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
392+
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=
393+
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
392394
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
393395
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
394396
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=

worker.go

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/zalando-incubator/kube-ingress-aws-controller/certs"
2020
"github.com/zalando-incubator/kube-ingress-aws-controller/kubernetes"
2121
"github.com/zalando-incubator/kube-ingress-aws-controller/problem"
22+
"golang.org/x/exp/slices"
2223
)
2324

2425
type loadBalancer struct {
@@ -455,8 +456,10 @@ func matchIngressesToLoadBalancers(
455456
// Ignore NLBs with a wrong set of subnets
456457
if lb.loadBalancerType == aws.LoadBalancerTypeNetwork {
457458
subnets := subnetsByScheme(lb.scheme)
459+
sort.Strings(subnets)
460+
sort.Strings(lb.stack.Subnets)
458461

459-
if !equalSlices[string](lb.stack.Subnets, subnets) {
462+
if !slices.Equal[string](lb.stack.Subnets, subnets) {
460463
continue
461464
}
462465
}
@@ -721,25 +724,3 @@ func cniEventHandler(ctx context.Context, targetCNIcfg *aws.TargetCNIconfig,
721724
}
722725
}
723726
}
724-
725-
func equalSlices[T comparable](a, b []T) bool {
726-
if len(a) != len(b) {
727-
return false
728-
}
729-
730-
for _, aElem := range a {
731-
found := false
732-
for _, bElem := range b {
733-
if aElem == bElem {
734-
found = true
735-
break
736-
}
737-
}
738-
739-
if !found {
740-
return false
741-
}
742-
}
743-
744-
return true
745-
}

0 commit comments

Comments
 (0)