Skip to content

Commit 3bf7d19

Browse files
yuval-ksoloio-bulldozer[bot]
authored andcommitted
Regex body (#35)
* allow extractors from body * speed test * Merge remote-tracking branch 'origin/master' into regex-body * dynamic meta * refactor metadata support * build * more tests * check empty output * add env var * fix segfault in test * add changelog * dynamic meta before headers * updates * add missing header; compile fix test * allow list bodies * test for regex in the ctor * remove * Merge remote-tracking branch 'origin/master' into regex-body * test that right fields are set in metadata * fix compile
1 parent da3f8af commit 3bf7d19

File tree

9 files changed

+528
-129
lines changed

9 files changed

+528
-129
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ BUILDIFIER=$GOPATH/bin/buildifier CLANG_FORMAT=clang-format /path/to/envoy/tools
5959

6060
# Submit a build
6161
```
62-
gcloud builds submit --config=cloudbuild.yaml \
62+
gcloud builds submit --project=solo-public --config=cloudbuild.yaml \
6363
--substitutions=COMMIT_SHA=$(git rev-parse HEAD) .
6464
```

api/envoy/config/filter/http/transformation/v2/transformation_filter.proto

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ option java_outer_classname = "TransformationFilterProto";
77
option java_multiple_files = true;
88
option go_package = "transformation";
99

10+
import "google/protobuf/empty.proto";
1011
import "validate/validate.proto";
1112

1213
import "envoy/api/v2/route/route.proto";
@@ -52,7 +53,10 @@ message Transformation {
5253
}
5354

5455
message Extraction {
55-
string header = 1;
56+
oneof source {
57+
string header = 1;
58+
google.protobuf.Empty body = 4;
59+
}
5660
// what information to extract. if extraction fails the result is
5761
// an empty value.
5862
string regex = 2;
@@ -61,7 +65,7 @@ message Extraction {
6165

6266
message TransformationTemplate {
6367
bool advanced_templates = 1;
64-
// Extractors are in the origin request language domain
68+
// Extractors are in the original request language domain
6569
map<string, Extraction> extractors = 2;
6670

6771
map<string, InjaTemplate> headers = 3;
@@ -71,6 +75,22 @@ message TransformationTemplate {
7175
Passthrough passthrough = 5;
7276
MergeExtractorsToBody merge_extractors_to_body = 6;
7377
}
78+
79+
enum RequestBodyParse {
80+
ParseAsJson = 0;
81+
DontParse = 1;
82+
}
83+
RequestBodyParse parse_body_behavior = 7;
84+
bool ignore_error_on_parse = 8;
85+
86+
message DynamicMetadataValue {
87+
// optional. if not set filter namespace will be used.
88+
string metadata_namespace = 1;
89+
string key = 2 [(validate.rules).string = {min_bytes: 1}];
90+
InjaTemplate value = 3;
91+
}
92+
repeated DynamicMetadataValue dynamic_metadata_values = 9;
93+
7494
}
7595

7696
/*

changelog/v0.1.18/body-transform.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
changelog:
2+
- type: NEW_FEATURE
3+
issueLink: https://github.com/solo-io/envoy-gloo/issues/37
4+
description: Add body() function to template, allow using templates wit dynamic metadata, add env() function to template

source/extensions/filters/http/transformation/BUILD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ envoy_cc_library(
8080
deps = [
8181
":transformer_lib",
8282
"//api/envoy/config/filter/http/transformation/v2:pkg_cc_proto",
83+
"//source/extensions/filters/http:solo_well_known_names",
8384
"@envoy//include/envoy/buffer:buffer_interface",
8485
"@envoy//include/envoy/http:header_map_interface",
8586
"@envoy//source/common/common:macros",
87+
"@envoy//source/common/common:regex_lib",
8688
"@envoy//source/common/common:utility_lib",
8789
"@envoy//source/common/protobuf",
88-
"@envoy//source/common/common:regex_lib",
8990
"@inja//:inja-lib",
9091
"@json//:json-lib",
9192
],

0 commit comments

Comments
 (0)