Skip to content

Commit

Permalink
Prevent the usage of routeSelectors in RLPs that target a Gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
guicassolato committed Jul 11, 2023
1 parent 9916c02 commit 61edeea
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api/v1beta2/ratelimitpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@ func (r *RateLimitPolicy) Validate() error {
return fmt.Errorf("invalid targetRef.Namespace %s. Currently only supporting references to the same namespace", *r.Spec.TargetRef.Namespace)
}

// prevents usage of routeSelectors in a gateway RLP
if r.Spec.TargetRef.Kind == gatewayapiv1alpha2.Kind("Gateway") {
for _, limit := range r.Spec.Limits {
if len(limit.RouteSelectors) > 0 {
return fmt.Errorf("route selectors not supported when targetting a Gateway")
}
}
}

return nil
}

Expand Down

0 comments on commit 61edeea

Please sign in to comment.