mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-12-07 21:01:33 +01:00
validate group and kind on the spec.parentRef. Move check into gwRouteHasParentRef
This commit is contained in:
parent
1476fe11a1
commit
9854a0ecb4
@ -307,16 +307,11 @@ func (c *gatewayRouteResolver) resolve(rt gatewayRoute) (map[string]endpoint.Tar
|
||||
for _, rps := range rt.RouteStatus().Parents {
|
||||
// Confirm the Parent is the standard Gateway kind.
|
||||
ref := rps.ParentRef
|
||||
// Ensure that the parent reference is in the routeParentRefs list
|
||||
found := false
|
||||
for _, rpr := range routeParentRefs {
|
||||
if string(rpr.Name) == string(ref.Name) && string(*rpr.Namespace) == string(*ref.Namespace) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
namespace := strVal((*string)(ref.Namespace), meta.Namespace)
|
||||
if !found {
|
||||
// Ensure that the parent reference is in the routeParentRefs list
|
||||
hasParentRef := gwRouteHasParentRef(routeParentRefs, ref, meta)
|
||||
|
||||
if !hasParentRef {
|
||||
log.Debugf("Parent reference %s/%s not found in routeParentRefs for %s %s/%s", namespace, string(ref.Name), c.src.rtKind, meta.Namespace, meta.Name)
|
||||
continue
|
||||
}
|
||||
@ -481,6 +476,26 @@ func (c *gatewayRouteResolver) routeIsAllowed(gw *v1beta1.Gateway, lis *v1.Liste
|
||||
return false
|
||||
}
|
||||
|
||||
func gwRouteHasParentRef(routeParentRefs []v1.ParentReference, ref v1.ParentReference, meta *metav1.ObjectMeta) bool {
|
||||
// Ensure that the parent reference is in the routeParentRefs list
|
||||
namespace := strVal((*string)(ref.Namespace), meta.Namespace)
|
||||
group := strVal((*string)(ref.Group), gatewayGroup)
|
||||
kind := strVal((*string)(ref.Kind), gatewayKind)
|
||||
for _, rpr := range routeParentRefs {
|
||||
rprGroup := strVal((*string)(rpr.Group), gatewayGroup)
|
||||
rprKind := strVal((*string)(rpr.Kind), gatewayKind)
|
||||
if rprGroup != group || rprKind != kind {
|
||||
continue
|
||||
}
|
||||
rprNamespace := strVal((*string)(rpr.Namespace), meta.Namespace)
|
||||
if string(rpr.Name) != string(ref.Name) || rprNamespace != namespace {
|
||||
continue
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func gwRouteIsAccepted(conds []metav1.Condition) bool {
|
||||
for _, c := range conds {
|
||||
if v1.RouteConditionType(c.Type) == v1.RouteConditionAccepted {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user