Skip to content

Commit

Permalink
Matchers: Add dynamic metadata to the http inputs (#34891)
Browse files Browse the repository at this point in the history
fixes: envoyproxy/envoy#34092

---------

Signed-off-by: Vikas Choudhary <[email protected]>

Mirrored from https://github.com/envoyproxy/envoy @ 520d88e4cb4e8c5014531281a88dcc8076e18bfd
  • Loading branch information
update-envoy[bot] committed Aug 5, 2024
1 parent 7354d0f commit 6bda828
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ proto_library(
"//envoy/extensions/matching/common_inputs/ssl/v3:pkg",
"//envoy/extensions/matching/input_matchers/consistent_hashing/v3:pkg",
"//envoy/extensions/matching/input_matchers/ip/v3:pkg",
"//envoy/extensions/matching/input_matchers/metadata/v3:pkg",
"//envoy/extensions/matching/input_matchers/runtime_fraction/v3:pkg",
"//envoy/extensions/network/dns_resolver/apple/v3:pkg",
"//envoy/extensions/network/dns_resolver/cares/v3:pkg",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,48 @@ message ApplicationProtocolInput {
message FilterStateInput {
string key = 1 [(validate.rules).string = {min_len: 1}];
}

// Input that matches dynamic metadata by key.
// DynamicMetadataInput provides a general interface using ``filter`` and ``path`` to retrieve value from
// :ref:`Metadata <envoy_v3_api_msg_config.core.v3.Metadata>`.
//
// For example, for the following Metadata:
//
// .. code-block:: yaml
//
// filter_metadata:
// envoy.xxx:
// prop:
// foo: bar
// xyz:
// hello: envoy
//
// The following DynamicMetadataInput will retrieve a string value "bar" from the Metadata.
//
// .. code-block:: yaml
//
// filter: envoy.xxx
// path:
// - key: prop
// - key: foo
//
// [#extension: envoy.matching.inputs.dynamic_metadata]
message DynamicMetadataInput {
// Specifies the segment in a path to retrieve value from Metadata.
// Note: Currently it's not supported to retrieve a value from a list in Metadata. This means that
// if the segment key refers to a list, it has to be the last segment in a path.
message PathSegment {
oneof segment {
option (validate.required) = true;

// If specified, use the key to retrieve the value in a Struct.
string key = 1 [(validate.rules).string = {min_len: 1}];
}
}

// The filter name to retrieve the Struct from the Metadata.
string filter = 1 [(validate.rules).string = {min_len: 1}];

// The path to retrieve the Value from the Struct.
repeated PathSegment path = 2 [(validate.rules).repeated = {min_items: 1}];
}
12 changes: 12 additions & 0 deletions envoy/extensions/matching/input_matchers/metadata/v3/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py.

load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")

licenses(["notice"]) # Apache 2

api_proto_package(
deps = [
"//envoy/type/matcher/v3:pkg",
"@com_github_cncf_xds//udpa/annotations:pkg",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
syntax = "proto3";

package envoy.extensions.matching.input_matchers.metadata.v3;

import "envoy/type/matcher/v3/value.proto";

import "udpa/annotations/status.proto";
import "validate/validate.proto";

option java_package = "io.envoyproxy.envoy.extensions.matching.input_matchers.metadata.v3";
option java_outer_classname = "MetadataProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/matching/input_matchers/metadata/v3;metadatav3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: metadata matcher]
// [#extension: envoy.matching.matchers.metadata_matcher]

// Metadata matcher for metadata from http matching input data.
message Metadata {
// The Metadata is matched if the value retrieved by metadata matching input is matched to this value.
type.matcher.v3.ValueMatcher value = 1 [(validate.rules).message = {required: true}];

// If true, the match result will be inverted.
bool invert = 4;
}
1 change: 1 addition & 0 deletions versioning/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ proto_library(
"//envoy/extensions/matching/common_inputs/ssl/v3:pkg",
"//envoy/extensions/matching/input_matchers/consistent_hashing/v3:pkg",
"//envoy/extensions/matching/input_matchers/ip/v3:pkg",
"//envoy/extensions/matching/input_matchers/metadata/v3:pkg",
"//envoy/extensions/matching/input_matchers/runtime_fraction/v3:pkg",
"//envoy/extensions/network/dns_resolver/apple/v3:pkg",
"//envoy/extensions/network/dns_resolver/cares/v3:pkg",
Expand Down

0 comments on commit 6bda828

Please sign in to comment.