Skip to content

Commit 5d4dac8

Browse files
nfudendavidjumani
andauthored
[1.18] plugins/aws: Requiretransform may be deprecated but still is in use (#10606)
Co-authored-by: David Jumani <[email protected]>
1 parent b9d791d commit 5d4dac8

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
changelog:
2+
- type: FIX
3+
issueLink: https://github.com/solo-io/solo-projects/issues/7882
4+
resolvesIssue: false
5+
description: Fixes a bug where the route ordering affects the deprecated aws requiretransform functionality.

projects/gloo/pkg/plugins/aws/plugin.go

+2-7
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,8 @@ func (p *Plugin) ProcessRoute(params plugins.RouteParams, in *v1.Route, out *env
259259
return nil, nil
260260
}
261261

262-
p.requiresTransformationFilter = true
263-
264262
var reqTransform *envoy_transform.Transformation
263+
var transform *envoy_transform.RouteTransformations_RouteTransformation
265264
if requiresRequestTransformation {
266265
reqTransform = &envoy_transform.Transformation{
267266
TransformationType: &envoy_transform.Transformation_HeaderBodyTransform{
@@ -270,10 +269,7 @@ func (p *Plugin) ProcessRoute(params plugins.RouteParams, in *v1.Route, out *env
270269
},
271270
},
272271
}
273-
}
274272

275-
var transform *envoy_transform.RouteTransformations_RouteTransformation
276-
if requiresRequestTransformation {
277273
// Early stage transform: place all headers in the request body
278274
transform = &envoy_transform.RouteTransformations_RouteTransformation{
279275
Stage: transformation.AwsStageNumber,
@@ -283,8 +279,7 @@ func (p *Plugin) ProcessRoute(params plugins.RouteParams, in *v1.Route, out *env
283279
},
284280
},
285281
}
286-
} else {
287-
p.requiresTransformationFilter = false
282+
p.requiresTransformationFilter = true
288283
}
289284

290285
var transforms envoy_transform.RouteTransformations

projects/gloo/pkg/plugins/aws/plugin_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,22 @@ var _ = Describe("Plugin", func() {
650650
err = awsPlugin.(plugins.RoutePlugin).ProcessRoute(plugins.RouteParams{VirtualHostParams: vhostParams}, route, outroute)
651651
Expect(err).To(MatchError("only one of unwrapAsAlb and unwrapAsApiGateway/responseTransformation may be set"))
652652
})
653+
It("should respect RequestTransformation irrespective of route ordering", func() {
654+
err := awsPlugin.(plugins.UpstreamPlugin).ProcessUpstream(params, upstream, out)
655+
Expect(err).NotTo(HaveOccurred())
656+
route.GetRouteAction().GetSingle().GetDestinationSpec().GetAws().RequestTransformation = true
657+
err = awsPlugin.(plugins.RoutePlugin).ProcessRoute(plugins.RouteParams{VirtualHostParams: vhostParams}, route, outroute)
658+
Expect(err).NotTo(HaveOccurred())
659+
660+
route.GetRouteAction().GetSingle().GetDestinationSpec().GetAws().RequestTransformation = false
661+
route.GetRouteAction().GetSingle().GetDestinationSpec().GetAws().UnwrapAsApiGateway = true
662+
err = awsPlugin.(plugins.RoutePlugin).ProcessRoute(plugins.RouteParams{VirtualHostParams: vhostParams}, route, outroute)
663+
Expect(err).NotTo(HaveOccurred())
664+
665+
filters, err := awsPlugin.(plugins.HttpFilterPlugin).HttpFilters(params, nil)
666+
Expect(err).NotTo(HaveOccurred())
667+
Expect(filters).To(HaveLen(2))
668+
})
653669
})
654670
})
655671

0 commit comments

Comments
 (0)