Skip to content

Commit

Permalink
NET-6946 - Replace usage of deprecated Envoy field envoy.config.route…
Browse files Browse the repository at this point in the history
….v3.HeaderMatcher.safe_regex_match
  • Loading branch information
jmurret committed Dec 21, 2023
1 parent a87ab8b commit 72c46cd
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 56 deletions.
14 changes: 8 additions & 6 deletions agent/xds/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -1106,10 +1106,8 @@ func parseXFCCToDynamicMetaHTTPFilter() (*envoy_http_v3.HttpFilter, error) {
Key: f.name,
RegexValueRewrite: &envoy_matcher_v3.RegexMatchAndSubstitute{
Pattern: &envoy_matcher_v3.RegexMatcher{
Regex: downstreamServiceIdentityMatcher,
EngineType: &envoy_matcher_v3.RegexMatcher_GoogleRe2{
GoogleRe2: &envoy_matcher_v3.RegexMatcher_GoogleRE2{},
},
Regex: downstreamServiceIdentityMatcher,
EngineType: &envoy_matcher_v3.RegexMatcher_GoogleRe2{},
},
Substitution: f.sub,
},
Expand Down Expand Up @@ -1310,8 +1308,12 @@ func convertPermission(perm *structs.IntentionPermission) *envoy_rbac_v3.Permiss

eh := &envoy_route_v3.HeaderMatcher{
Name: ":method",
HeaderMatchSpecifier: &envoy_route_v3.HeaderMatcher_SafeRegexMatch{
SafeRegexMatch: response.MakeEnvoyRegexMatch(methodHeaderRegex),
HeaderMatchSpecifier: &envoy_route_v3.HeaderMatcher_StringMatch{
StringMatch: &envoy_matcher_v3.StringMatcher{
MatchPattern: &envoy_matcher_v3.StringMatcher_SafeRegex{
SafeRegex: response.MakeEnvoyRegexMatch(methodHeaderRegex),
},
},
},
}

Expand Down
6 changes: 2 additions & 4 deletions agent/xds/response/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ func MakeBoolValue(n bool) *wrapperspb.BoolValue {

func MakeEnvoyRegexMatch(patt string) *envoy_matcher_v3.RegexMatcher {
return &envoy_matcher_v3.RegexMatcher{
EngineType: &envoy_matcher_v3.RegexMatcher_GoogleRe2{
GoogleRe2: &envoy_matcher_v3.RegexMatcher_GoogleRE2{},
},
Regex: patt,
EngineType: &envoy_matcher_v3.RegexMatcher_GoogleRe2{},
Regex: patt,
}
}
8 changes: 6 additions & 2 deletions agent/xds/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -926,8 +926,12 @@ func makeRouteMatchForDiscoveryRoute(discoveryRoute *structs.DiscoveryRoute) *en

eh := &envoy_route_v3.HeaderMatcher{
Name: ":method",
HeaderMatchSpecifier: &envoy_route_v3.HeaderMatcher_SafeRegexMatch{
SafeRegexMatch: response.MakeEnvoyRegexMatch(methodHeaderRegex),
HeaderMatchSpecifier: &envoy_route_v3.HeaderMatcher_StringMatch{
StringMatch: &envoy_matcher_v3.StringMatcher{
MatchPattern: &envoy_matcher_v3.StringMatcher_SafeRegex{
SafeRegex: response.MakeEnvoyRegexMatch(methodHeaderRegex),
},
},
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@
{
"header": {
"name": ":method",
"safeRegexMatch": {
"googleRe2": {},
"regex": "GET|HEAD|OPTIONS"
"stringMatch": {
"safeRegex": {
"googleRe2": {},
"regex": "GET|HEAD|OPTIONS"
}
}
}
}
Expand Down Expand Up @@ -191,9 +193,11 @@
{
"header": {
"name": ":method",
"safeRegexMatch": {
"googleRe2": {},
"regex": "GET|HEAD|OPTIONS"
"stringMatch": {
"safeRegex": {
"googleRe2": {},
"regex": "GET|HEAD|OPTIONS"
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@
{
"header": {
"name": ":method",
"safeRegexMatch": {
"googleRe2": {},
"regex": "GET|HEAD|OPTIONS"
"stringMatch": {
"safeRegex": {
"googleRe2": {},
"regex": "GET|HEAD|OPTIONS"
}
}
}
}
Expand Down Expand Up @@ -190,9 +192,11 @@
{
"header": {
"name": ":method",
"safeRegexMatch": {
"googleRe2": {},
"regex": "GET|HEAD|OPTIONS"
"stringMatch": {
"safeRegex": {
"googleRe2": {},
"regex": "GET|HEAD|OPTIONS"
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,11 @@
"headers": [
{
"name": ":method",
"safeRegexMatch": {
"googleRe2": {},
"regex": "GET|PUT"
"stringMatch": {
"safeRegex": {
"googleRe2": {},
"regex": "GET|PUT"
}
}
}
],
Expand All @@ -163,9 +165,11 @@
},
{
"name": ":method",
"safeRegexMatch": {
"googleRe2": {},
"regex": "GET|PUT"
"stringMatch": {
"safeRegex": {
"googleRe2": {},
"regex": "GET|PUT"
}
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,11 @@
"headers": [
{
"name": ":method",
"safeRegexMatch": {
"googleRe2": {},
"regex": "GET|PUT"
"stringMatch": {
"safeRegex": {
"googleRe2": {},
"regex": "GET|PUT"
}
}
}
],
Expand All @@ -202,9 +204,11 @@
},
{
"name": ":method",
"safeRegexMatch": {
"googleRe2": {},
"regex": "GET|PUT"
"stringMatch": {
"safeRegex": {
"googleRe2": {},
"regex": "GET|PUT"
}
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,11 @@
"headers": [
{
"name": ":method",
"safeRegexMatch": {
"googleRe2": {},
"regex": "GET|PUT"
"stringMatch": {
"safeRegex": {
"googleRe2": {},
"regex": "GET|PUT"
}
}
}
],
Expand All @@ -164,9 +166,11 @@
},
{
"name": ":method",
"safeRegexMatch": {
"googleRe2": {},
"regex": "GET|PUT"
"stringMatch": {
"safeRegex": {
"googleRe2": {},
"regex": "GET|PUT"
}
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,11 @@
"headers": [
{
"name": ":method",
"safeRegexMatch": {
"googleRe2": {},
"regex": "GET|PUT"
"stringMatch": {
"safeRegex": {
"googleRe2": {},
"regex": "GET|PUT"
}
}
}
],
Expand All @@ -164,9 +166,11 @@
},
{
"name": ":method",
"safeRegexMatch": {
"googleRe2": {},
"regex": "GET|PUT"
"stringMatch": {
"safeRegex": {
"googleRe2": {},
"regex": "GET|PUT"
}
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,11 @@
"headers": [
{
"name": ":method",
"safeRegexMatch": {
"googleRe2": {},
"regex": "GET|PUT"
"stringMatch": {
"safeRegex": {
"googleRe2": {},
"regex": "GET|PUT"
}
}
}
],
Expand All @@ -163,9 +165,11 @@
},
{
"name": ":method",
"safeRegexMatch": {
"googleRe2": {},
"regex": "GET|PUT"
"stringMatch": {
"safeRegex": {
"googleRe2": {},
"regex": "GET|PUT"
}
}
}
],
Expand Down
8 changes: 6 additions & 2 deletions agent/xdsv2/route_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,12 @@ func makeEnvoyRouteMatchFromProxystateRouteMatch(psRouteMatch *pbproxystate.Rout

eh := &envoy_route_v3.HeaderMatcher{
Name: ":method",
HeaderMatchSpecifier: &envoy_route_v3.HeaderMatcher_SafeRegexMatch{
SafeRegexMatch: makeEnvoyRegexMatch(methodHeaderRegex),
HeaderMatchSpecifier: &envoy_route_v3.HeaderMatcher_StringMatch{
StringMatch: &envoy_matcher_v3.StringMatcher{
MatchPattern: &envoy_matcher_v3.StringMatcher_SafeRegex{
SafeRegex: response.MakeEnvoyRegexMatch(methodHeaderRegex),
},
},
},
}

Expand Down

0 comments on commit 72c46cd

Please sign in to comment.