Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
899ec21
Init work with configuration proposition
Aug 12, 2019
6da905d
Added missing dependency
Aug 31, 2019
8eb6f82
Merge branch 'master' into local_reply_mapper
Aug 31, 2019
9bf0e6b
Without passed config
Aug 31, 2019
fc3c545
WIP config
Sep 2, 2019
c9a686e
Response flags added
Sep 3, 2019
4213f2e
Applied changes from code review
Sep 4, 2019
f8df3ae
repeated match
Sep 4, 2019
dac4695
Merge branch 'master' into local_reply_mapper
Sep 7, 2019
052aeeb
WIP local reply formatter with access log reuse
Sep 7, 2019
1499746
Merge branch 'master' into local_reply_mapper
Sep 13, 2019
8f022b6
Added mapper config
Sep 15, 2019
419a59c
Changed to access log filter
Sep 18, 2019
468308a
Merge branch 'master' into local_reply_mapper
Sep 19, 2019
1cce878
Cleanup and initial work docs
Sep 19, 2019
1efc2e3
Cleanup and initial work docs
Sep 19, 2019
7c75f6c
added comments
Sep 20, 2019
2670d0f
Added possibility to define custom format for each mapper
Sep 26, 2019
955bf79
Merge branch 'master' into local_reply_mapper
Sep 26, 2019
cd31254
Extracted new format StringOrJson
Sep 27, 2019
a77c82f
Removed docs and fixed format. I will provide docs file with implemen…
Oct 1, 2019
20abff0
Merge branch 'master' into local_reply_mapper
Oct 2, 2019
9c8d757
Added more docs
Oct 2, 2019
cc55bb4
Merge branch 'master' into local_reply_mapper
Oct 4, 2019
7784130
Code review fix
Oct 4, 2019
31f3cbf
Merge branch 'master' into local_reply_mapper
Oct 10, 2019
5eadeca
Fix build
Oct 11, 2019
199dd43
Merge branch 'master' into local_reply_mapper
Oct 11, 2019
0aee07a
Generated v3 files
Oct 11, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/envoy/config/filter/accesslog/v2/accesslog.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ message AccessLog {
}
}

// [#next-major-version: In the v3 API, we should consider renaming
// it to more generic filter]
message AccessLogFilter {
oneof filter_specifier {
option (validate.required) = true;
Expand Down
2 changes: 2 additions & 0 deletions api/envoy/config/filter/accesslog/v3alpha/accesslog.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ message AccessLog {
}
}

// [#next-major-version: In the v3 API, we should consider renaming
// it to more generic filter]
message AccessLogFilter {
oneof filter_specifier {
option (validate.required) = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import "envoy/api/v2/core/protocol.proto";
import "envoy/api/v2/rds.proto";
import "envoy/api/v2/srds.proto";
import "envoy/config/filter/accesslog/v2/accesslog.proto";
import "envoy/type/format.proto";
import "envoy/type/percent.proto";

import "google/protobuf/any.proto";
Expand All @@ -23,7 +24,7 @@ import "validate/validate.proto";
// [#protodoc-title: HTTP connection manager]
// HTTP connection manager :ref:`configuration overview <config_http_conn_man>`.

// [#comment:next free field: 36]
// [#comment:next free field: 37]
message HttpConnectionManager {
enum CodecType {
// For every new connection, the connection manager will determine which
Expand Down Expand Up @@ -461,6 +462,36 @@ message HttpConnectionManager {
// with `prefix` match set to `/dir`. Defaults to `false`. Note that slash merging is not part of
// `HTTP spec <https://tools.ietf.org/html/rfc3986>` and is provided for convenience.
bool merge_slashes = 33;

// [#not-implemented-hide:]
// Configuration of local reply returned by Envoy. Allows to specify mappings and format of
// response.
LocalReplyConfig local_reply_config = 36;
}

message LocalReplyConfig {
// Configuration of list of mappers which allows to filter and change local response.
// The client will iterate through mappers until first match.
repeated ResponseMapper mapper = 1;

// Allows to define custom format of local reply.
// It is allowed to use :ref:`command operators <config_access_log_command_operators>`
// which will be resolved to actual data.
type.StringOrJson format = 2;
}

message ResponseMapper {
// Filter is used to determine if the response should be changed.
accesslog.v2.AccessLogFilter filter = 1 [(validate.rules).message = {required: true}];

// Rewriter defines which values in local reply should be changed.
ResponseRewriter rewriter = 2 [(validate.rules).message = {required: true}];
}

// Configuration of new value for matched local response.
message ResponseRewriter {
// Status code for matched response.
google.protobuf.UInt32Value status_code = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this just be uint32?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will be good to keep this field optional if in future someone want to add e.g: headers, body.

}

message Rds {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import "envoy/api/v3alpha/rds.proto";
import "envoy/api/v3alpha/srds.proto";
import "envoy/config/filter/accesslog/v3alpha/accesslog.proto";
import "envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto";
import "envoy/type/v3alpha/format.proto";
import "envoy/type/v3alpha/percent.proto";

import "google/protobuf/any.proto";
Expand All @@ -24,7 +25,7 @@ import "validate/validate.proto";
// [#protodoc-title: HTTP connection manager]
// HTTP connection manager :ref:`configuration overview <config_http_conn_man>`.

// [#comment:next free field: 36]
// [#comment:next free field: 37]
message HttpConnectionManager {
enum CodecType {
// For every new connection, the connection manager will determine which
Expand Down Expand Up @@ -449,6 +450,36 @@ message HttpConnectionManager {
// with `prefix` match set to `/dir`. Defaults to `false`. Note that slash merging is not part of
// `HTTP spec <https://tools.ietf.org/html/rfc3986>` and is provided for convenience.
bool merge_slashes = 33;

// [#not-implemented-hide:]
// Configuration of local reply returned by Envoy. Allows to specify mappings and format of
// response.
LocalReplyConfig local_reply_config = 36;
}

message LocalReplyConfig {
// Configuration of list of mappers which allows to filter and change local response.
// The client will iterate through mappers until first match.
repeated ResponseMapper mapper = 1;

// Allows to define custom format of local reply.
// It is allowed to use :ref:`command operators <config_access_log_command_operators>`
// which will be resolved to actual data.
type.v3alpha.StringOrJson format = 2;
}

message ResponseMapper {
// Filter is used to determine if the response should be changed.
accesslog.v3alpha.AccessLogFilter filter = 1 [(validate.rules).message = {required: true}];

// Rewriter defines which values in local reply should be changed.
ResponseRewriter rewriter = 2 [(validate.rules).message = {required: true}];
}

// Configuration of new value for matched local response.
message ResponseRewriter {
// Status code for matched response.
google.protobuf.UInt32Value status_code = 1;
}

message Rds {
Expand Down
43 changes: 43 additions & 0 deletions api/envoy/type/format.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
syntax = "proto3";

package envoy.type;

option java_outer_classname = "FormatProto";
option java_multiple_files = true;
option java_package = "io.envoyproxy.envoy.type";

import "google/protobuf/struct.proto";

// [#protodoc-title: Format]

// Allows to define one of format: flat plain text or structured json.
message StringOrJson {
oneof format {
// Allows to specify flat plain text format.
//
// .. code-block:: yaml
//
// string_format: "My custom message"
//
string string_format = 1;

// Allows to specify structured data as json.
//
// .. code-block:: yaml
//
// json_format:
// protocol: "HTTP/1.1"
// message: "My message"
//
// The following JSON object would be created:
//
// .. code-block:: json
//
// {
// "protocol": "HTTP/1.1",
// "message": "My message"
// }
//
google.protobuf.Struct json_format = 2;
}
}
43 changes: 43 additions & 0 deletions api/envoy/type/v3alpha/format.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
syntax = "proto3";

package envoy.type.v3alpha;

option java_outer_classname = "FormatProto";
option java_multiple_files = true;
option java_package = "io.envoyproxy.envoy.type.v3alpha";

import "google/protobuf/struct.proto";

// [#protodoc-title: Format]

// Allows to define one of format: flat plain text or structured json.
message StringOrJson {
oneof format {
// Allows to specify flat plain text format.
//
// .. code-block:: yaml
//
// string_format: "My custom message"
//
string string_format = 1;

// Allows to specify structured data as json.
//
// .. code-block:: yaml
//
// json_format:
// protocol: "HTTP/1.1"
// message: "My message"
//
// The following JSON object would be created:
//
// .. code-block:: json
//
// {
// "protocol": "HTTP/1.1",
// "message": "My message"
// }
//
google.protobuf.Struct json_format = 2;
}
}
1 change: 1 addition & 0 deletions docs/root/api-v2/types/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Types
:glob:
:maxdepth: 2

../type/format.proto
../type/http_status.proto
../type/percent.proto
../type/range.proto
Expand Down
2 changes: 2 additions & 0 deletions docs/root/configuration/observability/access_log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ Format dictionaries have the following restrictions:

* The dictionary must map strings to strings (specifically, strings to command operators). Nesting is not currently supported.

.. _config_access_log_command_operators:

Command Operators
-----------------

Expand Down
64 changes: 64 additions & 0 deletions source/common/config/api_type_db.generated.pb_text

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tools/spelling_dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ resolvers
resync
ret
retriable
rewriter
rpcs
rq
rtrim
Expand Down