From 38583fea32ec48feb49eb000a1630fde6d0489ee Mon Sep 17 00:00:00 2001 From: Kamil Smigielski Date: Tue, 12 Nov 2024 12:34:06 +0100 Subject: [PATCH] add prefix rewrite --- .../servicemesh/envoycontrol/snapshot/SnapshotProperties.kt | 1 + .../snapshot/resource/routes/CustomRoutesFactory.kt | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotProperties.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotProperties.kt index d36feb317..d94f3305f 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotProperties.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotProperties.kt @@ -264,6 +264,7 @@ class AuthorizationProperties { class CustomRuteProperties { var enabled = false var cluster = "custom" + var prefixRewrite = "" var path = StringMatcher() } diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/CustomRoutesFactory.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/CustomRoutesFactory.kt index bf4bcf7f5..6858cfced 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/CustomRoutesFactory.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/CustomRoutesFactory.kt @@ -25,6 +25,11 @@ class CustomRoutesFactory(properties: RoutesProperties) { .setName(it.cluster) .setRoute(RouteAction.newBuilder() .setCluster(it.cluster) + .also { route -> + if (it.prefixRewrite != "") { + route.setPrefixRewrite(it.prefixRewrite) + } + } ) .setMatch(matcher) .build()