@@ -6,13 +6,15 @@ import (
6
6
"maps"
7
7
"time"
8
8
9
+ "google.golang.org/protobuf/proto"
9
10
"k8s.io/apimachinery/pkg/runtime"
10
11
"k8s.io/apimachinery/pkg/runtime/schema"
11
12
"k8s.io/apimachinery/pkg/watch"
12
13
13
14
envoy_config_cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
14
15
envoy_config_listener_v3 "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3"
15
16
envoy_config_route_v3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3"
17
+ envoydfp "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/dynamic_forward_proxy/v3"
16
18
awspb "github.com/solo-io/envoy-gloo/go/config/filter/http/aws_lambda/v2"
17
19
skubeclient "istio.io/istio/pkg/config/schema/kubeclient"
18
20
"istio.io/istio/pkg/kube/kclient"
@@ -62,7 +64,8 @@ func (d *upstreamDestination) Equals(in any) bool {
62
64
}
63
65
64
66
type UpstreamIr struct {
65
- AwsSecret * ir.Secret
67
+ AwsSecret * ir.Secret
68
+ dfpFilterConfig * envoydfp.FilterConfig
66
69
}
67
70
68
71
func (u * UpstreamIr ) data () map [string ][]byte {
@@ -77,13 +80,17 @@ func (u *UpstreamIr) Equals(other any) bool {
77
80
if ! ok {
78
81
return false
79
82
}
80
- return maps .EqualFunc (u .data (), otherUpstream .data (), func (a , b []byte ) bool {
83
+ if ! maps .EqualFunc (u .data (), otherUpstream .data (), func (a , b []byte ) bool {
81
84
return bytes .Equal (a , b )
82
- })
85
+ }) {
86
+ return false
87
+ }
88
+ return proto .Equal (otherUpstream .dfpFilterConfig , u .dfpFilterConfig )
83
89
}
84
90
85
91
type plugin2 struct {
86
- needFilter map [string ]bool
92
+ needAwsFilter map [string ]bool
93
+ neededDfpFilter map [string ]map [string ]* envoydfp.FilterConfig
87
94
}
88
95
89
96
func registerTypes (ourCli versioned.Interface ) {
@@ -171,6 +178,14 @@ func buildTranslateFunc(secrets *krtcollections.SecretIndex) func(krtctx krt.Han
171
178
// return error
172
179
}
173
180
}
181
+ if i .Spec .DynamicForwardProxy != nil {
182
+ ir .dfpFilterConfig = & envoydfp.FilterConfig {
183
+ ImplementationSpecifier : & envoydfp.FilterConfig_SubClusterConfig {
184
+ SubClusterConfig : & envoydfp.SubClusterConfig {},
185
+ },
186
+ }
187
+ }
188
+
174
189
return & ir
175
190
}
176
191
}
@@ -195,6 +210,8 @@ func processUpstream(ctx context.Context, in ir.Upstream, out *envoy_config_clus
195
210
processStatic (ctx , spec .Static , out )
196
211
case spec .Aws != nil :
197
212
processAws (ctx , spec .Aws , ir , out )
213
+ case spec .DynamicForwardProxy != nil :
214
+ processDFPCluster (ctx , spec .DynamicForwardProxy , out )
198
215
}
199
216
}
200
217
@@ -221,7 +238,10 @@ func processEndpoints(up *v1alpha1.Upstream) *ir.EndpointsForUpstream {
221
238
}
222
239
223
240
func newPlug (ctx context.Context , tctx ir.GwTranslationCtx ) ir.ProxyTranslationPass {
224
- return & plugin2 {}
241
+ return & plugin2 {
242
+ needAwsFilter : map [string ]bool {},
243
+ neededDfpFilter : map [string ]map [string ]* envoydfp.FilterConfig {},
244
+ }
225
245
}
226
246
227
247
func (p * plugin2 ) Name () string {
@@ -237,7 +257,7 @@ func (p *plugin2) ApplyVhostPlugin(ctx context.Context, pCtx *ir.VirtualHostCont
237
257
238
258
// called 0 or more times
239
259
func (p * plugin2 ) ApplyForRoute (ctx context.Context , pCtx * ir.RouteContext , outputRoute * envoy_config_route_v3.Route ) error {
240
-
260
+ p . processDFPRoute ( ctx , pCtx , outputRoute )
241
261
return nil
242
262
}
243
263
@@ -257,16 +277,20 @@ func (p *plugin2) ApplyForRouteBackend(
257
277
// if a plugin emits new filters, they must be with a plugin unique name.
258
278
// any filter returned from route config must be disabled, so it doesnt impact other routes.
259
279
func (p * plugin2 ) HttpFilters (ctx context.Context , fc ir.FilterChainCommon ) ([]plugins.StagedHttpFilter , error ) {
260
- if ! p .needFilter [fc .FilterChainName ] {
261
- return nil , nil
280
+ var ret []plugins.StagedHttpFilter
281
+ if p .needAwsFilter [fc .FilterChainName ] {
282
+ filterConfig := & awspb.AWSLambdaConfig {}
283
+ pluginStage := plugins .DuringStage (plugins .OutAuthStage )
284
+ f , _ := plugins .NewStagedFilter (FilterName , filterConfig , pluginStage )
285
+ ret = append (ret , f )
286
+ }
287
+ for clstrName , filterConfig := range p .neededDfpFilter [fc .FilterChainName ] {
288
+ pluginStage := plugins .DuringStage (plugins .OutAuthStage )
289
+ f , _ := plugins .NewStagedFilter (clstrName , filterConfig , pluginStage )
290
+ ret = append (ret , f )
262
291
}
263
- filterConfig := & awspb.AWSLambdaConfig {}
264
- pluginStage := plugins .DuringStage (plugins .OutAuthStage )
265
- f , _ := plugins .NewStagedFilter (FilterName , filterConfig , pluginStage )
266
292
267
- return []plugins.StagedHttpFilter {
268
- f ,
269
- }, nil
293
+ return ret , nil
270
294
}
271
295
272
296
func (p * plugin2 ) UpstreamHttpFilters (ctx context.Context ) ([]plugins.StagedUpstreamHttpFilter , error ) {
0 commit comments