@@ -34,7 +34,6 @@ import (
34
34
coreinformers "k8s.io/client-go/informers/core/v1"
35
35
cache "k8s.io/client-go/tools/cache"
36
36
v1 "sigs.k8s.io/gateway-api/apis/v1"
37
- "sigs.k8s.io/gateway-api/apis/v1alpha2"
38
37
v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
39
38
gateway "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned"
40
39
informers "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions"
@@ -55,6 +54,8 @@ type gatewayRoute interface {
55
54
Metadata () * metav1.ObjectMeta
56
55
// Hostnames returns the route's specified hostnames.
57
56
Hostnames () []v1.Hostname
57
+ // ParentRefs returns the route's parent references as defined in the route spec.
58
+ ParentRefs () []v1.ParentReference
58
59
// Protocol returns the route's protocol type.
59
60
Protocol () v1.ProtocolType
60
61
// RouteStatus returns the route's common status.
@@ -295,7 +296,7 @@ func (c *gatewayRouteResolver) resolve(rt gatewayRoute) (map[string]endpoint.Tar
295
296
}
296
297
hostTargets := make (map [string ]endpoint.Targets )
297
298
298
- routeParentRefs := getRouteParentRefs ( rt )
299
+ routeParentRefs := rt . ParentRefs ( )
299
300
300
301
if len (routeParentRefs ) == 0 {
301
302
log .Debugf ("No parent references found for %s %s/%s" , c .src .rtKind , rt .Metadata ().Namespace , rt .Metadata ().Name )
@@ -488,23 +489,6 @@ func gwRouteIsAccepted(conds []metav1.Condition) bool {
488
489
}
489
490
return false
490
491
}
491
- func getRouteParentRefs (rt gatewayRoute ) []v1.ParentReference {
492
- routeParentRefs := make ([]v1.ParentReference , 0 )
493
-
494
- switch rt .Object ().(type ) {
495
- case * v1.HTTPRoute :
496
- routeParentRefs = rt .Object ().(* v1.HTTPRoute ).Spec .ParentRefs
497
- case * v1.GRPCRoute :
498
- routeParentRefs = rt .Object ().(* v1.GRPCRoute ).Spec .ParentRefs
499
- case * v1alpha2.UDPRoute :
500
- routeParentRefs = rt .Object ().(* v1alpha2.UDPRoute ).Spec .ParentRefs
501
- case * v1alpha2.TCPRoute :
502
- routeParentRefs = rt .Object ().(* v1alpha2.TCPRoute ).Spec .ParentRefs
503
- case * v1alpha2.TLSRoute :
504
- routeParentRefs = rt .Object ().(* v1alpha2.TLSRoute ).Spec .ParentRefs
505
- }
506
- return routeParentRefs
507
- }
508
492
509
493
func uniqueTargets (targets endpoint.Targets ) endpoint.Targets {
510
494
if len (targets ) < 2 {
0 commit comments