diff --git a/api/envoy/config/filter/accesslog/v2/accesslog.proto b/api/envoy/config/filter/accesslog/v2/accesslog.proto index 8810e050e95f5..2fb81c29a08a5 100644 --- a/api/envoy/config/filter/accesslog/v2/accesslog.proto +++ b/api/envoy/config/filter/accesslog/v2/accesslog.proto @@ -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; diff --git a/api/envoy/config/filter/accesslog/v3alpha/accesslog.proto b/api/envoy/config/filter/accesslog/v3alpha/accesslog.proto index a257f4a229891..f4e87ef59ab86 100644 --- a/api/envoy/config/filter/accesslog/v3alpha/accesslog.proto +++ b/api/envoy/config/filter/accesslog/v3alpha/accesslog.proto @@ -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; diff --git a/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto b/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto index 6f4132e93504e..001cf9874260c 100644 --- a/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto +++ b/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto @@ -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"; @@ -23,7 +24,7 @@ import "validate/validate.proto"; // [#protodoc-title: HTTP connection manager] // HTTP connection manager :ref:`configuration overview `. -// [#comment:next free field: 36] +// [#comment:next free field: 37] message HttpConnectionManager { enum CodecType { // For every new connection, the connection manager will determine which @@ -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 ` 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 ` + // 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; } message Rds { diff --git a/api/envoy/config/filter/network/http_connection_manager/v3alpha/http_connection_manager.proto b/api/envoy/config/filter/network/http_connection_manager/v3alpha/http_connection_manager.proto index 9fe3396831f5a..88bd1e8c93337 100644 --- a/api/envoy/config/filter/network/http_connection_manager/v3alpha/http_connection_manager.proto +++ b/api/envoy/config/filter/network/http_connection_manager/v3alpha/http_connection_manager.proto @@ -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"; @@ -24,7 +25,7 @@ import "validate/validate.proto"; // [#protodoc-title: HTTP connection manager] // HTTP connection manager :ref:`configuration overview `. -// [#comment:next free field: 36] +// [#comment:next free field: 37] message HttpConnectionManager { enum CodecType { // For every new connection, the connection manager will determine which @@ -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 ` 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 ` + // 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 { diff --git a/api/envoy/type/format.proto b/api/envoy/type/format.proto new file mode 100644 index 0000000000000..4918b18816f13 --- /dev/null +++ b/api/envoy/type/format.proto @@ -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; + } +} diff --git a/api/envoy/type/v3alpha/format.proto b/api/envoy/type/v3alpha/format.proto new file mode 100644 index 0000000000000..cc0ee55745611 --- /dev/null +++ b/api/envoy/type/v3alpha/format.proto @@ -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; + } +} diff --git a/docs/root/api-v2/types/types.rst b/docs/root/api-v2/types/types.rst index a5a84c33a13d1..4ec77b14becf2 100644 --- a/docs/root/api-v2/types/types.rst +++ b/docs/root/api-v2/types/types.rst @@ -5,6 +5,7 @@ Types :glob: :maxdepth: 2 + ../type/format.proto ../type/http_status.proto ../type/percent.proto ../type/range.proto diff --git a/docs/root/configuration/observability/access_log.rst b/docs/root/configuration/observability/access_log.rst index 7ec4b57f08006..9c7df9d7e10c1 100644 --- a/docs/root/configuration/observability/access_log.rst +++ b/docs/root/configuration/observability/access_log.rst @@ -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 ----------------- diff --git a/source/common/config/api_type_db.generated.pb_text b/source/common/config/api_type_db.generated.pb_text index dd963044eb702..2d2895e397eb0 100644 --- a/source/common/config/api_type_db.generated.pb_text +++ b/source/common/config/api_type_db.generated.pb_text @@ -4913,6 +4913,14 @@ types { next_version_type_name: "envoy.config.filter.network.http_connection_manager.v3alpha.HttpFilter" } } +types { + key: "envoy.config.filter.network.http_connection_manager.v2.LocalReplyConfig" + value { + qualified_package: "envoy.config.filter.network.http_connection_manager.v2" + proto_path: "envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto" + next_version_type_name: "envoy.config.filter.network.http_connection_manager.v3alpha.LocalReplyConfig" + } +} types { key: "envoy.config.filter.network.http_connection_manager.v2.Rds" value { @@ -4921,6 +4929,22 @@ types { next_version_type_name: "envoy.config.filter.network.http_connection_manager.v3alpha.Rds" } } +types { + key: "envoy.config.filter.network.http_connection_manager.v2.ResponseMapper" + value { + qualified_package: "envoy.config.filter.network.http_connection_manager.v2" + proto_path: "envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto" + next_version_type_name: "envoy.config.filter.network.http_connection_manager.v3alpha.ResponseMapper" + } +} +types { + key: "envoy.config.filter.network.http_connection_manager.v2.ResponseRewriter" + value { + qualified_package: "envoy.config.filter.network.http_connection_manager.v2" + proto_path: "envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto" + next_version_type_name: "envoy.config.filter.network.http_connection_manager.v3alpha.ResponseRewriter" + } +} types { key: "envoy.config.filter.network.http_connection_manager.v2.ScopedRds" value { @@ -5047,6 +5071,13 @@ types { proto_path: "envoy/config/filter/network/http_connection_manager/v3alpha/http_connection_manager.proto" } } +types { + key: "envoy.config.filter.network.http_connection_manager.v3alpha.LocalReplyConfig" + value { + qualified_package: "envoy.config.filter.network.http_connection_manager.v3alpha" + proto_path: "envoy/config/filter/network/http_connection_manager/v3alpha/http_connection_manager.proto" + } +} types { key: "envoy.config.filter.network.http_connection_manager.v3alpha.Rds" value { @@ -5054,6 +5085,20 @@ types { proto_path: "envoy/config/filter/network/http_connection_manager/v3alpha/http_connection_manager.proto" } } +types { + key: "envoy.config.filter.network.http_connection_manager.v3alpha.ResponseMapper" + value { + qualified_package: "envoy.config.filter.network.http_connection_manager.v3alpha" + proto_path: "envoy/config/filter/network/http_connection_manager/v3alpha/http_connection_manager.proto" + } +} +types { + key: "envoy.config.filter.network.http_connection_manager.v3alpha.ResponseRewriter" + value { + qualified_package: "envoy.config.filter.network.http_connection_manager.v3alpha" + proto_path: "envoy/config/filter/network/http_connection_manager/v3alpha/http_connection_manager.proto" + } +} types { key: "envoy.config.filter.network.http_connection_manager.v3alpha.ScopedRds" value { @@ -7573,6 +7618,14 @@ types { next_version_type_name: "envoy.type.v3alpha.StatusCode" } } +types { + key: "envoy.type.StringOrJson" + value { + qualified_package: "envoy.type" + proto_path: "envoy/type/format.proto" + next_version_type_name: "envoy.type.v3alpha.StringOrJson" + } +} types { key: "envoy.type.matcher.DoubleMatcher" value { @@ -7772,6 +7825,13 @@ types { proto_path: "envoy/type/v3alpha/http_status.proto" } } +types { + key: "envoy.type.v3alpha.StringOrJson" + value { + qualified_package: "envoy.type.v3alpha" + proto_path: "envoy/type/v3alpha/format.proto" + } +} next_version_packages { key: "envoy.admin.v2alpha" value: "envoy.admin.v3alpha" @@ -8380,6 +8440,10 @@ next_version_proto_paths { key: "envoy/service/trace/v2/trace_service.proto" value: "envoy/service/trace/v3alpha/trace_service.proto" } +next_version_proto_paths { + key: "envoy/type/format.proto" + value: "envoy/type/v3alpha/format.proto" +} next_version_proto_paths { key: "envoy/type/http_status.proto" value: "envoy/type/v3alpha/http_status.proto" diff --git a/tools/spelling_dictionary.txt b/tools/spelling_dictionary.txt index 5f06b3af16563..9ed4da76b05c4 100644 --- a/tools/spelling_dictionary.txt +++ b/tools/spelling_dictionary.txt @@ -718,6 +718,7 @@ resolvers resync ret retriable +rewriter rpcs rq rtrim