Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Arko Dasgupta <arko@tetrate.io>
  • Loading branch information
arkodg committed Jan 21, 2023
1 parent 8af47cd commit 33a480c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/gatewayapi/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,12 +650,12 @@ func (t *Translator) processExtensionRefHTTPFilter(filter v1beta1.HTTPRouteFilte
t.processUnresolvedHTTPFilter(errMsg, filterContext)
return
}
filterContext.HTTPFilterChains.RateLimit = &ir.RateLimit{
rateLimit := &ir.RateLimit{
Global: &ir.GlobalRateLimit{
Rules: make([]*ir.RateLimitRule, len(rateLimitFilter.Spec.Global.Rules)),
},
}
rules := filterContext.HTTPFilterChains.RateLimit.Global.Rules
rules := rateLimit.Global.Rules
for i, rule := range rateLimitFilter.Spec.Global.Rules {
rules[i] = &ir.RateLimitRule{
Limit: &ir.RateLimitValue{
Expand Down Expand Up @@ -698,6 +698,7 @@ func (t *Translator) processExtensionRefHTTPFilter(filter v1beta1.HTTPRouteFilte
}

}
filterContext.HTTPFilterChains.RateLimit = rateLimit
return
}
}
Expand Down
5 changes: 5 additions & 0 deletions internal/gatewayapi/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ func (t *Translator) processHTTPRouteRule(httpRoute *HTTPRouteContext, ruleIdx i
if httpFiltersContext.RequestAuthentication != nil {
irRoute.RequestAuthentication = httpFiltersContext.RequestAuthentication
}
if httpFiltersContext.RateLimit != nil {
irRoute.RateLimit = httpFiltersContext.RateLimit
}

ruleRoutes = append(ruleRoutes, irRoute)
}

Expand Down Expand Up @@ -280,6 +284,7 @@ func (t *Translator) processHTTPRouteParentRefListener(httpRoute *HTTPRouteConte
URLRewrite: routeRoute.URLRewrite,
Mirrors: routeRoute.Mirrors,
RequestAuthentication: routeRoute.RequestAuthentication,
RateLimit: routeRoute.RateLimit,
}
// Don't bother copying over the weights unless the route has invalid backends.
if routeRoute.BackendWeights.Invalid > 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ xdsIR:
headerMatches:
- name: ":authority"
exact: gateway.envoyproxy.io
rateLimit:
global:
rules:
- headerMatches:
- name: "x-user-id"
exact: "one"
limit:
requests: 10
unit: Hour
destinations:
- host: 7.7.7.7
port: 8080
Expand Down

0 comments on commit 33a480c

Please sign in to comment.