@@ -128,6 +128,8 @@ func (r *gatewayQueries) GetRouteChain(
128
128
case * gwv1a2.TCPRoute :
129
129
backends = r .resolveRouteBackends (ctx , typedRoute )
130
130
// TODO (danehans): Should TCPRoute delegation support be added in the future?
131
+ case * gwv1a2.TLSRoute :
132
+ backends = r .resolveRouteBackends (ctx , typedRoute )
131
133
default :
132
134
return nil
133
135
}
@@ -151,7 +153,7 @@ func (r *gatewayQueries) allowedRoutes(gw *gwv1.Gateway, l *gwv1.Listener) (func
151
153
case gwv1 .HTTPProtocolType :
152
154
allowedKinds = []metav1.GroupKind {{Kind : wellknown .HTTPRouteKind , Group : gwv1 .GroupName }}
153
155
case gwv1 .TLSProtocolType :
154
- fallthrough
156
+ allowedKinds = []metav1. GroupKind {{ Kind : wellknown . TLSRouteKind , Group : gwv1a2 . GroupName }}
155
157
case gwv1 .TCPProtocolType :
156
158
allowedKinds = []metav1.GroupKind {{Kind : wellknown .TCPRouteKind , Group : gwv1a2 .GroupName }}
157
159
case gwv1 .UDPProtocolType :
@@ -228,6 +230,14 @@ func (r *gatewayQueries) resolveRouteBackends(ctx context.Context, obj client.Ob
228
230
}
229
231
processBackendRefs (refs )
230
232
}
233
+ case * gwv1a2.TLSRoute :
234
+ for _ , rule := range rt .Spec .Rules {
235
+ var refs []gwv1.BackendObjectReference
236
+ for _ , ref := range rule .BackendRefs {
237
+ refs = append (refs , ref .BackendObjectReference )
238
+ }
239
+ processBackendRefs (refs )
240
+ }
231
241
default :
232
242
return out
233
243
}
@@ -365,6 +375,16 @@ func (r *gatewayQueries) GetRoutesForGateway(ctx context.Context, gw *gwv1.Gatew
365
375
routeListTypes = append (routeListTypes , & gwv1a2.TCPRouteList {})
366
376
}
367
377
378
+ // Conditionally include TLSRouteList
379
+ tlsRouteGVK := schema.GroupVersionKind {
380
+ Group : gwv1a2 .GroupVersion .Group ,
381
+ Version : gwv1a2 .GroupVersion .Version ,
382
+ Kind : wellknown .TLSRouteKind ,
383
+ }
384
+ if r .scheme .Recognizes (tlsRouteGVK ) {
385
+ routeListTypes = append (routeListTypes , & gwv1a2.TLSRouteList {})
386
+ }
387
+
368
388
var routes []client.Object
369
389
for _ , routeList := range routeListTypes {
370
390
if err := fetchRoutes (ctx , r , routeList , nns , & routes ); err != nil {
@@ -406,6 +426,10 @@ func fetchRoutes(ctx context.Context, r *gatewayQueries, routeList client.Object
406
426
if err := listAndAppendRoutes (list , TcpRouteTargetField ); err != nil {
407
427
return fmt .Errorf ("failed to list TCPRoutes: %w" , err )
408
428
}
429
+ case * gwv1a2.TLSRouteList :
430
+ if err := listAndAppendRoutes (list , TlsRouteTargetField ); err != nil {
431
+ return fmt .Errorf ("failed to list TLSRoutes: %w" , err )
432
+ }
409
433
default :
410
434
return fmt .Errorf ("unsupported route list type: %T" , list )
411
435
}
@@ -452,12 +476,22 @@ func (r *gatewayQueries) processRoute(ctx context.Context, gw *gwv1.Gateway, rou
452
476
}
453
477
anyListenerMatched = true
454
478
455
- // If the route is an HTTPRoute, check the hostname intersection
479
+ // If the route is an HTTPRoute or TLSRoute , check the hostname intersection
456
480
var hostnames []string
457
481
if routeKind == wellknown .HTTPRouteKind {
458
482
if hr , ok := route .(* gwv1.HTTPRoute ); ok {
459
483
var ok bool
460
- ok , hostnames = hostnameIntersect (& l , hr )
484
+ ok , hostnames = hostnameIntersect (& l , hr .Spec .Hostnames )
485
+ if ! ok {
486
+ continue
487
+ }
488
+ anyHostsMatch = true
489
+ }
490
+ }
491
+ if routeKind == wellknown .TLSRouteKind {
492
+ if tr , ok := route .(* gwv1a2.TLSRoute ); ok {
493
+ var ok bool
494
+ ok , hostnames = hostnameIntersect (& l , tr .Spec .Hostnames )
461
495
if ! ok {
462
496
continue
463
497
}
@@ -532,6 +566,12 @@ func getRouteItems(list client.ObjectList) ([]client.Object, error) {
532
566
objs = append (objs , & routes .Items [i ])
533
567
}
534
568
return objs , nil
569
+ case * gwv1a2.TLSRouteList :
570
+ var objs []client.Object
571
+ for i := range routes .Items {
572
+ objs = append (objs , & routes .Items [i ])
573
+ }
574
+ return objs , nil
535
575
default :
536
576
return nil , fmt .Errorf ("unsupported route type %T" , list )
537
577
}
0 commit comments