mirror of https://github.com/status-im/consul.git
api-gateway: stop adding all header filters to virtual host when generating xDS (#17644)
* Add header filter to api-gateway xDS golden test * Stop adding all header filters to virtual host when generating xDS for api-gateway * Regenerate xDS golden file for api-gateway w/ header filter
This commit is contained in:
parent
baaf6d84c7
commit
1074252361
|
@ -415,6 +415,19 @@ func getAPIGatewayGoldenTestCases(t *testing.T) []goldenTestCase {
|
|||
Kind: structs.HTTPRoute,
|
||||
Name: "route",
|
||||
Rules: []structs.HTTPRouteRule{{
|
||||
Filters: structs.HTTPFilters{
|
||||
Headers: []structs.HTTPHeaderFilter{
|
||||
{
|
||||
Add: map[string]string{
|
||||
"X-Header-Add": "added",
|
||||
},
|
||||
Set: map[string]string{
|
||||
"X-Header-Set": "set",
|
||||
},
|
||||
Remove: []string{"X-Header-Remove"},
|
||||
},
|
||||
},
|
||||
},
|
||||
Services: []structs.HTTPService{{
|
||||
Name: "service",
|
||||
}},
|
||||
|
|
|
@ -477,8 +477,6 @@ func (s *ResourceGenerator) routesForAPIGateway(cfgSnap *proxycfg.ConfigSnapshot
|
|||
return nil, err
|
||||
}
|
||||
|
||||
addHeaderFiltersToVirtualHost(&reformatedRoute, virtualHost)
|
||||
|
||||
defaultRoute.VirtualHosts = append(defaultRoute.VirtualHosts, virtualHost)
|
||||
}
|
||||
|
||||
|
@ -1097,16 +1095,6 @@ func injectHeaderManipToRoute(dest *structs.ServiceRouteDestination, r *envoy_ro
|
|||
return nil
|
||||
}
|
||||
|
||||
func addHeaderFiltersToVirtualHost(dest *structs.HTTPRouteConfigEntry, vh *envoy_route_v3.VirtualHost) {
|
||||
for _, rule := range dest.Rules {
|
||||
for _, header := range rule.Filters.Headers {
|
||||
vh.RequestHeadersToAdd = append(vh.RequestHeadersToAdd, makeHeadersValueOptions(header.Add, true)...)
|
||||
vh.RequestHeadersToAdd = append(vh.RequestHeadersToAdd, makeHeadersValueOptions(header.Set, false)...)
|
||||
vh.RequestHeadersToRemove = append(vh.RequestHeadersToRemove, header.Remove...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func injectHeaderManipToVirtualHost(dest *structs.IngressService, vh *envoy_route_v3.VirtualHost) error {
|
||||
if !dest.RequestHeaders.IsZero() {
|
||||
vh.RequestHeadersToAdd = append(
|
||||
|
|
|
@ -18,7 +18,26 @@
|
|||
},
|
||||
"route": {
|
||||
"cluster": "service.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul"
|
||||
},
|
||||
"requestHeadersToAdd": [
|
||||
{
|
||||
"header": {
|
||||
"key": "X-Header-Add",
|
||||
"value": "added"
|
||||
},
|
||||
"append": true
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"key": "X-Header-Set",
|
||||
"value": "set"
|
||||
},
|
||||
"append": false
|
||||
}
|
||||
],
|
||||
"requestHeadersToRemove": [
|
||||
"X-Header-Remove"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue