File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
internal/controller/state/graph Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -287,7 +287,8 @@ func getAndValidateListenerSupportedKinds(listener v1.Listener) (
287287 }
288288
289289 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 )
291292 for _ , kind := range listener .AllowedRoutes .Kinds {
292293 if ! validProtocolRouteKind (kind ) {
293294 group := v1 .GroupName
@@ -298,7 +299,15 @@ func getAndValidateListenerSupportedKinds(listener v1.Listener) (
298299 conds = append (conds , conditions .NewListenerInvalidRouteKinds (msg )... )
299300 continue
300301 }
301- supportedKinds = append (supportedKinds , kind )
302+ // Use group/kind as key for uniqueness
303+ key := string (kind .Kind )
304+ if kind .Group != nil {
305+ key = string (* kind .Group ) + "/" + key
306+ }
307+ if _ , exists := unique [key ]; ! exists {
308+ unique [key ] = struct {}{}
309+ supportedKinds = append (supportedKinds , kind )
310+ }
302311 }
303312 return conds , supportedKinds
304313 }
Original file line number Diff line number Diff line change @@ -382,6 +382,20 @@ func TestGetAndValidateListenerSupportedKinds(t *testing.T) {
382382 name : "valid and invalid kinds" ,
383383 expected : []v1.RouteGroupKind {HTTPRouteGroupKind },
384384 },
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+ },
385399 {
386400 protocol : v1 .TLSProtocolType ,
387401 kind : []v1.RouteGroupKind {
You can’t perform that action at this time.
0 commit comments