File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
internal/controller/state/graph Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -287,7 +287,8 @@ func getAndValidateListenerSupportedKinds(listener v1.Listener) (
287
287
}
288
288
289
289
if listener .AllowedRoutes != nil && listener .AllowedRoutes .Kinds != nil {
290
- supportedKinds = make ([]v1.RouteGroupKind , 0 , len (listener .AllowedRoutes .Kinds ))
290
+ unique := make (map [string ]struct {})
291
+ supportedKinds = make ([]v1.RouteGroupKind , 0 )
291
292
for _ , kind := range listener .AllowedRoutes .Kinds {
292
293
if ! validProtocolRouteKind (kind ) {
293
294
group := v1 .GroupName
@@ -298,7 +299,12 @@ func getAndValidateListenerSupportedKinds(listener v1.Listener) (
298
299
conds = append (conds , conditions .NewListenerInvalidRouteKinds (msg )... )
299
300
continue
300
301
}
301
- supportedKinds = append (supportedKinds , kind )
302
+ // Use kind as key for uniqueness
303
+ key := string (kind .Kind )
304
+ if _ , exists := unique [key ]; ! exists {
305
+ unique [key ] = struct {}{}
306
+ supportedKinds = append (supportedKinds , kind )
307
+ }
302
308
}
303
309
return conds , supportedKinds
304
310
}
Original file line number Diff line number Diff line change @@ -382,6 +382,20 @@ func TestGetAndValidateListenerSupportedKinds(t *testing.T) {
382
382
name : "valid and invalid kinds" ,
383
383
expected : []v1.RouteGroupKind {HTTPRouteGroupKind },
384
384
},
385
+ {
386
+ protocol : v1 .HTTPProtocolType ,
387
+ kind : []v1.RouteGroupKind {
388
+ HTTPRouteGroupKind ,
389
+ GRPCRouteGroupKind ,
390
+ GRPCRouteGroupKind ,
391
+ },
392
+ expectErr : false ,
393
+ name : "handle duplicate kinds" ,
394
+ expected : []v1.RouteGroupKind {
395
+ HTTPRouteGroupKind ,
396
+ GRPCRouteGroupKind ,
397
+ },
398
+ },
385
399
{
386
400
protocol : v1 .TLSProtocolType ,
387
401
kind : []v1.RouteGroupKind {
You can’t perform that action at this time.
0 commit comments