Skip to content

Commit

Permalink
fix: Deprecated field error when using RequestHeaderModifier filter (#…
Browse files Browse the repository at this point in the history
…2574)

Signed-off-by: David Alger <davidmalger@gmail.com>
  • Loading branch information
davidalger authored Feb 8, 2024
1 parent 9b37f59 commit a33c505
Showing 4 changed files with 24 additions and 22 deletions.
10 changes: 9 additions & 1 deletion internal/xds/translator/route.go
Original file line number Diff line number Diff line change
@@ -329,12 +329,20 @@ func buildXdsAddedHeaders(headersToAdd []ir.AddHeader) []*corev3.HeaderValueOpti
headerValueOptions := make([]*corev3.HeaderValueOption, len(headersToAdd))

for i, header := range headersToAdd {
var appendAction corev3.HeaderValueOption_HeaderAppendAction

if header.Append {
appendAction = corev3.HeaderValueOption_APPEND_IF_EXISTS_OR_ADD
} else {
appendAction = corev3.HeaderValueOption_OVERWRITE_IF_EXISTS_OR_ADD
}

headerValueOptions[i] = &corev3.HeaderValueOption{
Header: &corev3.HeaderValue{
Key: header.Name,
Value: header.Value,
},
Append: &wrapperspb.BoolValue{Value: header.Append},
AppendAction: appendAction,
}

// Allow empty headers to be set, but don't add the config to do so unless necessary
Original file line number Diff line number Diff line change
@@ -9,23 +9,21 @@
prefix: /
name: request-header-route
requestHeadersToAdd:
- append: true
header:
- header:
key: some-header
value: some-value
- append: true
header:
- header:
key: some-header-2
value: some-value
- append: false
- appendAction: OVERWRITE_IF_EXISTS_OR_ADD
header:
key: some-header3
value: some-value
- append: false
- appendAction: OVERWRITE_IF_EXISTS_OR_ADD
header:
key: some-header4
value: some-value
- append: false
- appendAction: OVERWRITE_IF_EXISTS_OR_ADD
header:
key: empty-header
keepEmptyValue: true
Original file line number Diff line number Diff line change
@@ -9,23 +9,21 @@
prefix: /
name: response-header-route
responseHeadersToAdd:
- append: true
header:
- header:
key: some-header
value: some-value
- append: true
header:
- header:
key: some-header-2
value: some-value
- append: false
- appendAction: OVERWRITE_IF_EXISTS_OR_ADD
header:
key: some-header3
value: some-value
- append: false
- appendAction: OVERWRITE_IF_EXISTS_OR_ADD
header:
key: some-header4
value: some-value
- append: false
- appendAction: OVERWRITE_IF_EXISTS_OR_ADD
header:
key: empty-header
keepEmptyValue: true
Original file line number Diff line number Diff line change
@@ -9,23 +9,21 @@
prefix: /
name: response-header-route
responseHeadersToAdd:
- append: true
header:
- header:
key: some-header
value: some-value
- append: true
header:
- header:
key: some-header-2
value: some-value
- append: false
- appendAction: OVERWRITE_IF_EXISTS_OR_ADD
header:
key: some-header3
value: some-value
- append: false
- appendAction: OVERWRITE_IF_EXISTS_OR_ADD
header:
key: some-header4
value: some-value
- append: false
- appendAction: OVERWRITE_IF_EXISTS_OR_ADD
header:
key: empty-header
keepEmptyValue: true

0 comments on commit a33c505

Please sign in to comment.