| 1 |
syntax = "proto3"; |
| 2 |
|
| 3 |
package xds.type.matcher.v3; |
| 4 |
|
| 5 |
import "xds/core/v3/extension.proto"; |
| 6 |
import "xds/type/matcher/v3/string.proto"; |
| 7 |
|
| 8 |
import "validate/validate.proto"; |
| 9 |
|
| 10 |
option java_package = "com.github.xds.type.matcher.v3"; |
| 11 |
option java_outer_classname = "MatcherProto"; |
| 12 |
option java_multiple_files = true; |
| 13 |
option go_package = "github.com/cncf/xds/go/xds/type/matcher/v3"; |
| 14 |
|
| 15 |
// [#protodoc-title: Unified Matcher API] |
| 16 |
|
| 17 |
// A matcher, which may traverse a matching tree in order to result in a match action. |
| 18 |
// During matching, the tree will be traversed until a match is found, or if no match |
| 19 |
// is found the action specified by the most specific on_no_match will be evaluated. |
| 20 |
// As an on_no_match might result in another matching tree being evaluated, this process |
| 21 |
// might repeat several times until the final OnMatch (or no match) is decided. |
| 22 |
message Matcher { |
| 23 |
// What to do if a match is successful. |
| 24 |
message OnMatch { |
| 25 |
oneof on_match { |
| 26 |
option (validate.required) = true; |
| 27 |
|
| 28 |
// Nested matcher to evaluate. |
| 29 |
// If the nested matcher does not match and does not specify |
| 30 |
// on_no_match, then this matcher is considered not to have |
| 31 |
// matched, even if a predicate at this level or above returned |
| 32 |
// true. |
| 33 |
Matcher matcher = 1; |
| 34 |
|
| 35 |
// Protocol-specific action to take. |
| 36 |
core.v3.TypedExtensionConfig action = 2; |
| 37 |
} |
| 38 |
|
| 39 |
// If true and the Matcher matches, the action will be taken but the caller |
| 40 |
// will behave as if the Matcher did not match. A subsequent matcher or |
| 41 |
// on_no_match action will be used instead. |
| 42 |
// This field is not supported in all contexts in which the matcher API is |
| 43 |
// used. If this field is set in a context in which it's not supported, |
| 44 |
// the resource will be rejected. |
| 45 |
bool keep_matching = 3; |
| 46 |
} |
| 47 |
|
| 48 |
// A linear list of field matchers. |
| 49 |
// The field matchers are evaluated in order, and the first match |
| 50 |
// wins. |
| 51 |
message MatcherList { |
| 52 |
// Predicate to determine if a match is successful. |
| 53 |
message Predicate { |
| 54 |
// Predicate for a single input field. |
| 55 |
message SinglePredicate { |
| 56 |
// Protocol-specific specification of input field to match on. |
| 57 |
// [#extension-category: envoy.matching.common_inputs] |
| 58 |
core.v3.TypedExtensionConfig input = 1 [(validate.rules).message = {required: true}]; |
| 59 |
|
| 60 |
oneof matcher { |
| 61 |
option (validate.required) = true; |
| 62 |
|
| 63 |
// Built-in string matcher. |
| 64 |
type.matcher.v3.StringMatcher value_match = 2; |
| 65 |
|
| 66 |
// Extension for custom matching logic. |
| 67 |
// [#extension-category: envoy.matching.input_matchers] |
| 68 |
core.v3.TypedExtensionConfig custom_match = 3; |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
// A list of two or more matchers. Used to allow using a list within a oneof. |
| 73 |
message PredicateList { |
| 74 |
repeated Predicate predicate = 1 [(validate.rules).repeated = {min_items: 2}]; |
| 75 |
} |
| 76 |
|
| 77 |
oneof match_type { |
| 78 |
option (validate.required) = true; |
| 79 |
|
| 80 |
// A single predicate to evaluate. |
| 81 |
SinglePredicate single_predicate = 1; |
| 82 |
|
| 83 |
// A list of predicates to be OR-ed together. |
| 84 |
PredicateList or_matcher = 2; |
| 85 |
|
| 86 |
// A list of predicates to be AND-ed together. |
| 87 |
PredicateList and_matcher = 3; |
| 88 |
|
| 89 |
// The invert of a predicate |
| 90 |
Predicate not_matcher = 4; |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
// An individual matcher. |
| 95 |
message FieldMatcher { |
| 96 |
// Determines if the match succeeds. |
| 97 |
Predicate predicate = 1 [(validate.rules).message = {required: true}]; |
| 98 |
|
| 99 |
// What to do if the match succeeds. |
| 100 |
OnMatch on_match = 2 [(validate.rules).message = {required: true}]; |
| 101 |
} |
| 102 |
|
| 103 |
// A list of matchers. First match wins. |
| 104 |
repeated FieldMatcher matchers = 1 [(validate.rules).repeated = {min_items: 1}]; |
| 105 |
} |
| 106 |
|
| 107 |
message MatcherTree { |
| 108 |
// A map of configured matchers. Used to allow using a map within a oneof. |
| 109 |
message MatchMap { |
| 110 |
map<string, OnMatch> map = 1 [(validate.rules).map = {min_pairs: 1}]; |
| 111 |
} |
| 112 |
|
| 113 |
// Protocol-specific specification of input field to match on. |
| 114 |
core.v3.TypedExtensionConfig input = 1 [(validate.rules).message = {required: true}]; |
| 115 |
|
| 116 |
// Exact or prefix match maps in which to look up the input value. |
| 117 |
// If the lookup succeeds, the match is considered successful, and |
| 118 |
// the corresponding OnMatch is used. |
| 119 |
oneof tree_type { |
| 120 |
option (validate.required) = true; |
| 121 |
|
| 122 |
MatchMap exact_match_map = 2; |
| 123 |
|
| 124 |
// Longest matching prefix wins. |
| 125 |
MatchMap prefix_match_map = 3; |
| 126 |
|
| 127 |
// Extension for custom matching logic. |
| 128 |
core.v3.TypedExtensionConfig custom_match = 4; |
| 129 |
} |
| 130 |
} |
| 131 |
|
| 132 |
oneof matcher_type { |
| 133 |
// A linear list of matchers to evaluate. |
| 134 |
MatcherList matcher_list = 1; |
| 135 |
|
| 136 |
// A match tree to evaluate. |
| 137 |
MatcherTree matcher_tree = 2; |
| 138 |
} |
| 139 |
|
| 140 |
// Optional OnMatch to use if no matcher above matched (e.g., if there are no matchers specified |
| 141 |
// above, or if none of the matches specified above succeeded). |
| 142 |
// If no matcher above matched and this field is not populated, the match will be considered unsuccessful. |
| 143 |
OnMatch on_no_match = 3; |
| 144 |
} |