NET-6945 - Replace usage of deprecated Envoy field envoy.config.core.v3.HeaderValueOption.append (#20078)

* NET-6945 - Replace usage of deprecated Envoy field envoy.config.core.v3.HeaderValueOption.append

* update proto for v2 and then update xds v2 logic

* add changelog

* Update 20078.txt to be consistent with existing changelog entries

* swap enum values tomatch envoy.
This commit is contained in:
John Murret 2024-01-03 17:36:25 -07:00 committed by GitHub
parent 55d7e95a3e
commit 7a410d7c5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 101 additions and 97 deletions

3
.changelog/20078.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
connect: Replace usage of deprecated Envoy field `envoy.config.core.v3.HeaderValueOption.append`.
```

View File

@ -534,7 +534,10 @@ func makeHeadersValueOptions(vals map[string]string, add bool) []*envoy_core_v3.
Key: k, Key: k,
Value: v, Value: v,
}, },
Append: response.MakeBoolValue(add), }
if !add {
// default is APPEND_IF_EXISTS_OR_ADD
o.AppendAction = envoy_core_v3.HeaderValueOption_OVERWRITE_IF_EXISTS_OR_ADD
} }
opts = append(opts, o) opts = append(opts, o)
} }
@ -1130,6 +1133,7 @@ func injectLBToRouteAction(lb *structs.LoadBalancer, action *envoy_route_v3.Rout
} }
func injectHeaderManipToRoute(dest *structs.ServiceRouteDestination, r *envoy_route_v3.Route) error { func injectHeaderManipToRoute(dest *structs.ServiceRouteDestination, r *envoy_route_v3.Route) error {
if !dest.RequestHeaders.IsZero() { if !dest.RequestHeaders.IsZero() {
r.RequestHeadersToAdd = append( r.RequestHeadersToAdd = append(
r.RequestHeadersToAdd, r.RequestHeadersToAdd,

View File

@ -19,14 +19,13 @@
}, },
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": true,
"header": { "header": {
"key": "X-Header-Add", "key": "X-Header-Add",
"value": "added" "value": "added"
} }
}, },
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "X-Header-Set", "key": "X-Header-Set",
"value": "set" "value": "set"

View File

@ -19,14 +19,13 @@
}, },
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": true,
"header": { "header": {
"key": "X-Header-Add", "key": "X-Header-Add",
"value": "added" "value": "added"
} }
}, },
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "X-Header-Set", "key": "X-Header-Set",
"value": "set" "value": "set"

View File

@ -23,7 +23,7 @@
"name": "big-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", "name": "big-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "big" "value": "big"
@ -32,7 +32,7 @@
], ],
"responseHeadersToAdd": [ "responseHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "big" "value": "big"
@ -45,7 +45,7 @@
"name": "goldilocks-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", "name": "goldilocks-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "goldilocks" "value": "goldilocks"
@ -54,7 +54,7 @@
], ],
"responseHeadersToAdd": [ "responseHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "goldilocks" "value": "goldilocks"
@ -67,7 +67,7 @@
"name": "lil-bit-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", "name": "lil-bit-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "small" "value": "small"
@ -76,7 +76,7 @@
], ],
"responseHeadersToAdd": [ "responseHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "small" "value": "small"

View File

@ -369,14 +369,13 @@
}, },
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": true,
"header": { "header": {
"key": "request", "key": "request",
"value": "bar" "value": "bar"
} }
}, },
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "bar", "key": "bar",
"value": "baz" "value": "baz"
@ -388,14 +387,13 @@
], ],
"responseHeadersToAdd": [ "responseHeadersToAdd": [
{ {
"append": true,
"header": { "header": {
"key": "response", "key": "response",
"value": "bar" "value": "bar"
} }
}, },
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "bar", "key": "bar",
"value": "baz" "value": "baz"

View File

@ -41,7 +41,7 @@
"name": "db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", "name": "db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "db" "value": "db"
@ -50,7 +50,7 @@
], ],
"responseHeadersToAdd": [ "responseHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "db" "value": "db"
@ -63,7 +63,7 @@
"name": "big-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", "name": "big-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "big" "value": "big"
@ -72,7 +72,7 @@
], ],
"responseHeadersToAdd": [ "responseHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "big" "value": "big"
@ -85,7 +85,7 @@
"name": "goldilocks-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", "name": "goldilocks-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "goldilocks" "value": "goldilocks"
@ -94,7 +94,7 @@
], ],
"responseHeadersToAdd": [ "responseHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "goldilocks" "value": "goldilocks"
@ -107,7 +107,7 @@
"name": "lil-bit-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", "name": "lil-bit-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "small" "value": "small"
@ -116,7 +116,7 @@
], ],
"responseHeadersToAdd": [ "responseHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "small" "value": "small"

View File

@ -14,14 +14,13 @@
"name": "db", "name": "db",
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": true,
"header": { "header": {
"key": "foo", "key": "foo",
"value": "bar" "value": "bar"
} }
}, },
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "bar", "key": "bar",
"value": "baz" "value": "baz"
@ -33,14 +32,13 @@
], ],
"responseHeadersToAdd": [ "responseHeadersToAdd": [
{ {
"append": true,
"header": { "header": {
"key": "foo", "key": "foo",
"value": "bar" "value": "bar"
} }
}, },
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "bar", "key": "bar",
"value": "baz" "value": "baz"
@ -408,14 +406,13 @@
}, },
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": true,
"header": { "header": {
"key": "request", "key": "request",
"value": "bar" "value": "bar"
} }
}, },
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "bar", "key": "bar",
"value": "baz" "value": "baz"
@ -427,14 +424,13 @@
], ],
"responseHeadersToAdd": [ "responseHeadersToAdd": [
{ {
"append": true,
"header": { "header": {
"key": "response", "key": "response",
"value": "bar" "value": "bar"
} }
}, },
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "bar", "key": "bar",
"value": "baz" "value": "baz"

View File

@ -370,14 +370,13 @@
}, },
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": true,
"header": { "header": {
"key": "request", "key": "request",
"value": "bar" "value": "bar"
} }
}, },
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "bar", "key": "bar",
"value": "baz" "value": "baz"
@ -389,14 +388,13 @@
], ],
"responseHeadersToAdd": [ "responseHeadersToAdd": [
{ {
"append": true,
"header": { "header": {
"key": "response", "key": "response",
"value": "bar" "value": "bar"
} }
}, },
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "bar", "key": "bar",
"value": "baz" "value": "baz"

View File

@ -42,7 +42,7 @@
"name": "db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", "name": "db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "db" "value": "db"
@ -51,7 +51,7 @@
], ],
"responseHeadersToAdd": [ "responseHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "db" "value": "db"
@ -64,7 +64,7 @@
"name": "big-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", "name": "big-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "big" "value": "big"
@ -73,7 +73,7 @@
], ],
"responseHeadersToAdd": [ "responseHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "big" "value": "big"
@ -86,7 +86,7 @@
"name": "goldilocks-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", "name": "goldilocks-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "goldilocks" "value": "goldilocks"
@ -95,7 +95,7 @@
], ],
"responseHeadersToAdd": [ "responseHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "goldilocks" "value": "goldilocks"
@ -108,7 +108,7 @@
"name": "lil-bit-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", "name": "lil-bit-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "small" "value": "small"
@ -117,7 +117,7 @@
], ],
"responseHeadersToAdd": [ "responseHeadersToAdd": [
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "x-split-leg", "key": "x-split-leg",
"value": "small" "value": "small"

View File

@ -370,14 +370,13 @@
}, },
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": true,
"header": { "header": {
"key": "request", "key": "request",
"value": "bar" "value": "bar"
} }
}, },
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "bar", "key": "bar",
"value": "baz" "value": "baz"
@ -389,14 +388,13 @@
], ],
"responseHeadersToAdd": [ "responseHeadersToAdd": [
{ {
"append": true,
"header": { "header": {
"key": "response", "key": "response",
"value": "bar" "value": "bar"
} }
}, },
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "bar", "key": "bar",
"value": "baz" "value": "baz"

View File

@ -369,14 +369,13 @@
}, },
"requestHeadersToAdd": [ "requestHeadersToAdd": [
{ {
"append": true,
"header": { "header": {
"key": "request", "key": "request",
"value": "bar" "value": "bar"
} }
}, },
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "bar", "key": "bar",
"value": "baz" "value": "baz"
@ -388,14 +387,13 @@
], ],
"responseHeadersToAdd": [ "responseHeadersToAdd": [
{ {
"append": true,
"header": { "header": {
"key": "response", "key": "response",
"value": "bar" "value": "bar"
} }
}, },
{ {
"append": false, "appendAction": "OVERWRITE_IF_EXISTS_OR_ADD",
"header": { "header": {
"key": "bar", "key": "bar",
"value": "baz" "value": "baz"

View File

@ -328,20 +328,29 @@ func makeEnvoyClusterWeightFromNameAndWeight(name string, weight *wrapperspb.UIn
return envoyClusterWeight return envoyClusterWeight
} }
func getXDSAppendActionFromProxyStateAppendAction(action pbproxystate.AppendAction) envoy_core_v3.HeaderValueOption_HeaderAppendAction {
if action == pbproxystate.AppendAction_APPEND_ACTION_OVERWRITE_IF_EXISTS_OR_ADD {
return envoy_core_v3.HeaderValueOption_OVERWRITE_IF_EXISTS_OR_ADD
} else if action == pbproxystate.AppendAction_APPEND_ACTION_ADD_IF_ABSENT {
return envoy_core_v3.HeaderValueOption_ADD_IF_ABSENT
}
// XDS default
return envoy_core_v3.HeaderValueOption_APPEND_IF_EXISTS_OR_ADD
}
func injectEnvoyClusterWeightWithProxystateHeaderMutation(envoyClusterWeight *envoy_route_v3.WeightedCluster_ClusterWeight, mutation *pbproxystate.HeaderMutation) { func injectEnvoyClusterWeightWithProxystateHeaderMutation(envoyClusterWeight *envoy_route_v3.WeightedCluster_ClusterWeight, mutation *pbproxystate.HeaderMutation) {
mutation.GetAction() mutation.GetAction()
switch mutation.GetAction().(type) { switch mutation.GetAction().(type) {
case *pbproxystate.HeaderMutation_RequestHeaderAdd: case *pbproxystate.HeaderMutation_RequestHeaderAdd:
action := mutation.GetRequestHeaderAdd() action := mutation.GetRequestHeaderAdd()
header := action.GetHeader() header := action.GetHeader()
app := action.GetAppendAction() == pbproxystate.AppendAction_APPEND_ACTION_APPEND_IF_EXISTS_OR_ADD
hvo := &envoy_core_v3.HeaderValueOption{ hvo := &envoy_core_v3.HeaderValueOption{
Header: &envoy_core_v3.HeaderValue{ Header: &envoy_core_v3.HeaderValue{
Key: header.GetKey(), Key: header.GetKey(),
Value: header.GetValue(), Value: header.GetValue(),
}, },
Append: response.MakeBoolValue(app), AppendAction: getXDSAppendActionFromProxyStateAppendAction(action.GetAppendAction()),
} }
envoyClusterWeight.RequestHeadersToAdd = append(envoyClusterWeight.RequestHeadersToAdd, hvo) envoyClusterWeight.RequestHeadersToAdd = append(envoyClusterWeight.RequestHeadersToAdd, hvo)
@ -352,14 +361,13 @@ func injectEnvoyClusterWeightWithProxystateHeaderMutation(envoyClusterWeight *en
case *pbproxystate.HeaderMutation_ResponseHeaderAdd: case *pbproxystate.HeaderMutation_ResponseHeaderAdd:
action := mutation.GetResponseHeaderAdd() action := mutation.GetResponseHeaderAdd()
header := action.GetHeader() header := action.GetHeader()
app := action.GetAppendAction() == pbproxystate.AppendAction_APPEND_ACTION_APPEND_IF_EXISTS_OR_ADD
hvo := &envoy_core_v3.HeaderValueOption{ hvo := &envoy_core_v3.HeaderValueOption{
Header: &envoy_core_v3.HeaderValue{ Header: &envoy_core_v3.HeaderValue{
Key: header.GetKey(), Key: header.GetKey(),
Value: header.GetValue(), Value: header.GetValue(),
}, },
Append: response.MakeBoolValue(app), AppendAction: getXDSAppendActionFromProxyStateAppendAction(action.GetAppendAction()),
} }
envoyClusterWeight.ResponseHeadersToAdd = append(envoyClusterWeight.ResponseHeadersToAdd, hvo) envoyClusterWeight.ResponseHeadersToAdd = append(envoyClusterWeight.ResponseHeadersToAdd, hvo)
@ -457,14 +465,13 @@ func injectEnvoyRouteRuleWithProxystateHeaderMutation(envoyRouteRule *envoy_rout
case *pbproxystate.HeaderMutation_RequestHeaderAdd: case *pbproxystate.HeaderMutation_RequestHeaderAdd:
action := mutation.GetRequestHeaderAdd() action := mutation.GetRequestHeaderAdd()
header := action.GetHeader() header := action.GetHeader()
app := action.GetAppendAction() == pbproxystate.AppendAction_APPEND_ACTION_APPEND_IF_EXISTS_OR_ADD
hvo := &envoy_core_v3.HeaderValueOption{ hvo := &envoy_core_v3.HeaderValueOption{
Header: &envoy_core_v3.HeaderValue{ Header: &envoy_core_v3.HeaderValue{
Key: header.GetKey(), Key: header.GetKey(),
Value: header.GetValue(), Value: header.GetValue(),
}, },
Append: response.MakeBoolValue(app), AppendAction: getXDSAppendActionFromProxyStateAppendAction(action.GetAppendAction()),
} }
envoyRouteRule.RequestHeadersToAdd = append(envoyRouteRule.RequestHeadersToAdd, hvo) envoyRouteRule.RequestHeadersToAdd = append(envoyRouteRule.RequestHeadersToAdd, hvo)
@ -475,14 +482,13 @@ func injectEnvoyRouteRuleWithProxystateHeaderMutation(envoyRouteRule *envoy_rout
case *pbproxystate.HeaderMutation_ResponseHeaderAdd: case *pbproxystate.HeaderMutation_ResponseHeaderAdd:
action := mutation.GetResponseHeaderAdd() action := mutation.GetResponseHeaderAdd()
header := action.GetHeader() header := action.GetHeader()
app := action.GetAppendAction() == pbproxystate.AppendAction_APPEND_ACTION_APPEND_IF_EXISTS_OR_ADD
hvo := &envoy_core_v3.HeaderValueOption{ hvo := &envoy_core_v3.HeaderValueOption{
Header: &envoy_core_v3.HeaderValue{ Header: &envoy_core_v3.HeaderValue{
Key: header.GetKey(), Key: header.GetKey(),
Value: header.GetValue(), Value: header.GetValue(),
}, },
Append: response.MakeBoolValue(app), AppendAction: getXDSAppendActionFromProxyStateAppendAction(action.GetAppendAction()),
} }
envoyRouteRule.ResponseHeadersToAdd = append(envoyRouteRule.ResponseHeadersToAdd, hvo) envoyRouteRule.ResponseHeadersToAdd = append(envoyRouteRule.ResponseHeadersToAdd, hvo)
@ -502,14 +508,13 @@ func injectEnvoyVirtualHostWithProxystateHeaderMutation(envoyVirtualHost *envoy_
case *pbproxystate.HeaderMutation_RequestHeaderAdd: case *pbproxystate.HeaderMutation_RequestHeaderAdd:
action := mutation.GetRequestHeaderAdd() action := mutation.GetRequestHeaderAdd()
header := action.GetHeader() header := action.GetHeader()
app := action.GetAppendAction() == pbproxystate.AppendAction_APPEND_ACTION_APPEND_IF_EXISTS_OR_ADD
hvo := &envoy_core_v3.HeaderValueOption{ hvo := &envoy_core_v3.HeaderValueOption{
Header: &envoy_core_v3.HeaderValue{ Header: &envoy_core_v3.HeaderValue{
Key: header.GetKey(), Key: header.GetKey(),
Value: header.GetValue(), Value: header.GetValue(),
}, },
Append: response.MakeBoolValue(app), AppendAction: getXDSAppendActionFromProxyStateAppendAction(action.GetAppendAction()),
} }
envoyVirtualHost.RequestHeadersToAdd = append(envoyVirtualHost.RequestHeadersToAdd, hvo) envoyVirtualHost.RequestHeadersToAdd = append(envoyVirtualHost.RequestHeadersToAdd, hvo)
@ -520,14 +525,13 @@ func injectEnvoyVirtualHostWithProxystateHeaderMutation(envoyVirtualHost *envoy_
case *pbproxystate.HeaderMutation_ResponseHeaderAdd: case *pbproxystate.HeaderMutation_ResponseHeaderAdd:
action := mutation.GetResponseHeaderAdd() action := mutation.GetResponseHeaderAdd()
header := action.GetHeader() header := action.GetHeader()
app := action.GetAppendAction() == pbproxystate.AppendAction_APPEND_ACTION_APPEND_IF_EXISTS_OR_ADD
hvo := &envoy_core_v3.HeaderValueOption{ hvo := &envoy_core_v3.HeaderValueOption{
Header: &envoy_core_v3.HeaderValue{ Header: &envoy_core_v3.HeaderValue{
Key: header.GetKey(), Key: header.GetKey(),
Value: header.GetValue(), Value: header.GetValue(),
}, },
Append: response.MakeBoolValue(app), AppendAction: getXDSAppendActionFromProxyStateAppendAction(action.GetAppendAction()),
} }
envoyVirtualHost.ResponseHeadersToAdd = append(envoyVirtualHost.ResponseHeadersToAdd, hvo) envoyVirtualHost.ResponseHeadersToAdd = append(envoyVirtualHost.ResponseHeadersToAdd, hvo)

View File

@ -30,18 +30,21 @@ type AppendAction int32
const ( const (
// buf:lint:ignore ENUM_ZERO_VALUE_SUFFIX // buf:lint:ignore ENUM_ZERO_VALUE_SUFFIX
AppendAction_APPEND_ACTION_APPEND_IF_EXISTS_OR_ADD AppendAction = 0 AppendAction_APPEND_ACTION_APPEND_IF_EXISTS_OR_ADD AppendAction = 0
AppendAction_APPEND_ACTION_OVERWRITE_IF_EXISTS_OR_ADD AppendAction = 1 AppendAction_APPEND_ACTION_ADD_IF_ABSENT AppendAction = 1
AppendAction_APPEND_ACTION_OVERWRITE_IF_EXISTS_OR_ADD AppendAction = 2
) )
// Enum value maps for AppendAction. // Enum value maps for AppendAction.
var ( var (
AppendAction_name = map[int32]string{ AppendAction_name = map[int32]string{
0: "APPEND_ACTION_APPEND_IF_EXISTS_OR_ADD", 0: "APPEND_ACTION_APPEND_IF_EXISTS_OR_ADD",
1: "APPEND_ACTION_OVERWRITE_IF_EXISTS_OR_ADD", 1: "APPEND_ACTION_ADD_IF_ABSENT",
2: "APPEND_ACTION_OVERWRITE_IF_EXISTS_OR_ADD",
} }
AppendAction_value = map[string]int32{ AppendAction_value = map[string]int32{
"APPEND_ACTION_APPEND_IF_EXISTS_OR_ADD": 0, "APPEND_ACTION_APPEND_IF_EXISTS_OR_ADD": 0,
"APPEND_ACTION_OVERWRITE_IF_EXISTS_OR_ADD": 1, "APPEND_ACTION_ADD_IF_ABSENT": 1,
"APPEND_ACTION_OVERWRITE_IF_EXISTS_OR_ADD": 2,
} }
) )
@ -517,35 +520,38 @@ var file_pbmesh_v2beta1_pbproxystate_header_mutations_proto_rawDesc = []byte{
0x30, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x30, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76,
0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75,
0x65, 0x2a, 0x67, 0x0a, 0x0c, 0x41, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x65, 0x2a, 0x88, 0x01, 0x0a, 0x0c, 0x41, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x41, 0x63, 0x74, 0x69,
0x6e, 0x12, 0x29, 0x0a, 0x25, 0x41, 0x50, 0x50, 0x45, 0x4e, 0x44, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x6f, 0x6e, 0x12, 0x29, 0x0a, 0x25, 0x41, 0x50, 0x50, 0x45, 0x4e, 0x44, 0x5f, 0x41, 0x43, 0x54,
0x4f, 0x4e, 0x5f, 0x41, 0x50, 0x50, 0x45, 0x4e, 0x44, 0x5f, 0x49, 0x46, 0x5f, 0x45, 0x58, 0x49, 0x49, 0x4f, 0x4e, 0x5f, 0x41, 0x50, 0x50, 0x45, 0x4e, 0x44, 0x5f, 0x49, 0x46, 0x5f, 0x45, 0x58,
0x53, 0x54, 0x53, 0x5f, 0x4f, 0x52, 0x5f, 0x41, 0x44, 0x44, 0x10, 0x00, 0x12, 0x2c, 0x0a, 0x28, 0x49, 0x53, 0x54, 0x53, 0x5f, 0x4f, 0x52, 0x5f, 0x41, 0x44, 0x44, 0x10, 0x00, 0x12, 0x1f, 0x0a,
0x41, 0x50, 0x50, 0x45, 0x4e, 0x44, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4f, 0x56, 0x1b, 0x41, 0x50, 0x50, 0x45, 0x4e, 0x44, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x41,
0x45, 0x52, 0x57, 0x52, 0x49, 0x54, 0x45, 0x5f, 0x49, 0x46, 0x5f, 0x45, 0x58, 0x49, 0x53, 0x54, 0x44, 0x44, 0x5f, 0x49, 0x46, 0x5f, 0x41, 0x42, 0x53, 0x45, 0x4e, 0x54, 0x10, 0x01, 0x12, 0x2c,
0x53, 0x5f, 0x4f, 0x52, 0x5f, 0x41, 0x44, 0x44, 0x10, 0x01, 0x42, 0xda, 0x02, 0x0a, 0x2e, 0x63, 0x0a, 0x28, 0x41, 0x50, 0x50, 0x45, 0x4e, 0x44, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f,
0x6f, 0x6d, 0x2e, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2e, 0x63, 0x6f, 0x6e, 0x4f, 0x56, 0x45, 0x52, 0x57, 0x52, 0x49, 0x54, 0x45, 0x5f, 0x49, 0x46, 0x5f, 0x45, 0x58, 0x49,
0x73, 0x75, 0x6c, 0x2e, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x62, 0x65, 0x74, 0x61, 0x31, 0x53, 0x54, 0x53, 0x5f, 0x4f, 0x52, 0x5f, 0x41, 0x44, 0x44, 0x10, 0x02, 0x42, 0xda, 0x02, 0x0a,
0x2e, 0x70, 0x62, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x73, 0x74, 0x61, 0x74, 0x65, 0x42, 0x14, 0x48, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2e, 0x63,
0x65, 0x61, 0x64, 0x65, 0x72, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x50, 0x72, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x2e, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x62, 0x65, 0x74,
0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x61, 0x31, 0x2e, 0x70, 0x62, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x73, 0x74, 0x61, 0x74, 0x65, 0x42,
0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x14, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73,
0x75, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x2f, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
0x70, 0x62, 0x6d, 0x65, 0x73, 0x68, 0x2f, 0x76, 0x32, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x70, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x63, 0x6f,
0x62, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x73, 0x74, 0x61, 0x74, 0x65, 0xa2, 0x02, 0x05, 0x48, 0x43, 0x6e, 0x73, 0x75, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2d, 0x70, 0x75, 0x62, 0x6c, 0x69,
0x4d, 0x56, 0x50, 0xaa, 0x02, 0x2a, 0x48, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2e, 0x63, 0x2f, 0x70, 0x62, 0x6d, 0x65, 0x73, 0x68, 0x2f, 0x76, 0x32, 0x62, 0x65, 0x74, 0x61, 0x31,
0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x2e, 0x4d, 0x65, 0x73, 0x68, 0x2e, 0x56, 0x32, 0x62, 0x65, 0x2f, 0x70, 0x62, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x73, 0x74, 0x61, 0x74, 0x65, 0xa2, 0x02, 0x05,
0x74, 0x61, 0x31, 0x2e, 0x50, 0x62, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x73, 0x74, 0x61, 0x74, 0x65, 0x48, 0x43, 0x4d, 0x56, 0x50, 0xaa, 0x02, 0x2a, 0x48, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72,
0xca, 0x02, 0x2a, 0x48, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x5c, 0x43, 0x6f, 0x6e, 0x70, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x2e, 0x4d, 0x65, 0x73, 0x68, 0x2e, 0x56, 0x32,
0x73, 0x75, 0x6c, 0x5c, 0x4d, 0x65, 0x73, 0x68, 0x5c, 0x56, 0x32, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x62, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x73, 0x74, 0x61,
0x5c, 0x50, 0x62, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x73, 0x74, 0x61, 0x74, 0x65, 0xe2, 0x02, 0x36, 0x74, 0x65, 0xca, 0x02, 0x2a, 0x48, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x5c, 0x43,
0x48, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x5c, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x5c, 0x4d, 0x65, 0x73, 0x68, 0x5c, 0x56, 0x32, 0x62, 0x65, 0x74,
0x5c, 0x4d, 0x65, 0x73, 0x68, 0x5c, 0x56, 0x32, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x50, 0x62, 0x61, 0x31, 0x5c, 0x50, 0x62, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x73, 0x74, 0x61, 0x74, 0x65, 0xe2,
0x70, 0x72, 0x6f, 0x78, 0x79, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x02, 0x36, 0x48, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x5c, 0x43, 0x6f, 0x6e, 0x73,
0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x2e, 0x48, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x75, 0x6c, 0x5c, 0x4d, 0x65, 0x73, 0x68, 0x5c, 0x56, 0x32, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c,
0x72, 0x70, 0x3a, 0x3a, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x3a, 0x3a, 0x4d, 0x65, 0x73, 0x68, 0x50, 0x62, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5c, 0x47, 0x50, 0x42,
0x3a, 0x3a, 0x56, 0x32, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3a, 0x3a, 0x50, 0x62, 0x70, 0x72, 0x6f, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x2e, 0x48, 0x61, 0x73, 0x68, 0x69,
0x78, 0x79, 0x73, 0x74, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x63, 0x6f, 0x72, 0x70, 0x3a, 0x3a, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x3a, 0x3a, 0x4d, 0x65,
0x73, 0x68, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3a, 0x3a, 0x50, 0x62, 0x70,
0x72, 0x6f, 0x78, 0x79, 0x73, 0x74, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
} }
var ( var (

View File

@ -45,5 +45,6 @@ message Header {
enum AppendAction { enum AppendAction {
// buf:lint:ignore ENUM_ZERO_VALUE_SUFFIX // buf:lint:ignore ENUM_ZERO_VALUE_SUFFIX
APPEND_ACTION_APPEND_IF_EXISTS_OR_ADD = 0; APPEND_ACTION_APPEND_IF_EXISTS_OR_ADD = 0;
APPEND_ACTION_OVERWRITE_IF_EXISTS_OR_ADD = 1; APPEND_ACTION_ADD_IF_ABSENT = 1;
APPEND_ACTION_OVERWRITE_IF_EXISTS_OR_ADD = 2;
} }