@@ -34,7 +34,6 @@ import (
3434 coreinformers "k8s.io/client-go/informers/core/v1"
3535 cache "k8s.io/client-go/tools/cache"
3636 v1 "sigs.k8s.io/gateway-api/apis/v1"
37- "sigs.k8s.io/gateway-api/apis/v1alpha2"
3837 v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
3938 gateway "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned"
4039 informers "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions"
@@ -55,6 +54,8 @@ type gatewayRoute interface {
5554 Metadata () * metav1.ObjectMeta
5655 // Hostnames returns the route's specified hostnames.
5756 Hostnames () []v1.Hostname
57+ // ParentRefs returns the route's parent references as defined in the route spec.
58+ ParentRefs () []v1.ParentReference
5859 // Protocol returns the route's protocol type.
5960 Protocol () v1.ProtocolType
6061 // RouteStatus returns the route's common status.
@@ -295,7 +296,7 @@ func (c *gatewayRouteResolver) resolve(rt gatewayRoute) (map[string]endpoint.Tar
295296 }
296297 hostTargets := make (map [string ]endpoint.Targets )
297298
298- routeParentRefs := getRouteParentRefs ( rt )
299+ routeParentRefs := rt . ParentRefs ( )
299300
300301 if len (routeParentRefs ) == 0 {
301302 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 {
488489 }
489490 return false
490491}
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- }
508492
509493func uniqueTargets (targets endpoint.Targets ) endpoint.Targets {
510494 if len (targets ) < 2 {
0 commit comments