-
Notifications
You must be signed in to change notification settings - Fork 829
api: add ordered header mutations to ClientTrafficPolicy header filter #9555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1052,6 +1052,20 @@ type CustomRedirect struct { | |
| // multiple values for a header must use RFC 7230 header value formatting, | ||
| // separating each value with a comma. | ||
| type HTTPHeaderFilter struct { | ||
| // Mutations is an ordered list of header operations that are applied in | ||
| // exactly the order specified. Use this field when the sequence of | ||
| // operations matters, for example setting a header and then appending to | ||
| // it, or removing a header and then re-adding it. | ||
| // | ||
| // Mutations are always applied FIRST, in list order. The Set, Add, | ||
| // AddIfAbsent, Remove and RemoveOnMatch fields below are then applied after | ||
| // the mutations, preserving their existing ordering (Add, then Set, then | ||
| // AddIfAbsent, then Remove, then RemoveOnMatch). | ||
| // | ||
| // +optional | ||
| // +kubebuilder:validation:MaxItems=64 | ||
| Mutations []HTTPHeaderMutation `json:"mutations,omitempty"` | ||
|
Comment on lines
+1065
to
+1067
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a ClientTrafficPolicy uses Useful? React with 👍 / 👎.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is for API only discussion.
Comment on lines
+1055
to
+1067
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This commit exposes a new user-facing ClientTrafficPolicy header-mutation API and updates the generated docs/CRDs, but it does not add any Useful? React with 👍 / 👎.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is API only for discussion. |
||
|
|
||
| // Set overwrites the request with the given header (name, value) | ||
| // before the action. | ||
| // | ||
|
|
@@ -1156,6 +1170,75 @@ type HTTPHeaderFilter struct { | |
| RemoveOnMatch []StringMatch `json:"removeOnMatch,omitempty"` | ||
| } | ||
|
|
||
| // HTTPHeaderMutation defines a single header mutation operation. | ||
| // | ||
| // +kubebuilder:validation:MaxProperties=1 | ||
| // +kubebuilder:validation:MinProperties=1 | ||
| type HTTPHeaderMutation struct { | ||
| // Write adds or modifies a header using the specified action. | ||
| // | ||
| // +optional | ||
| Write *HTTPHeaderWrite `json:"write,omitempty"` | ||
|
|
||
| // Remove removes the named header if it exists. Header names are | ||
| // case-insensitive. | ||
| // | ||
| // +optional | ||
| Remove *string `json:"remove,omitempty"` | ||
|
|
||
| // RemoveOnMatch removes every header whose name matches the specified string | ||
| // matcher. Matching is performed on the header name (case-insensitive). | ||
| // | ||
| // +optional | ||
| RemoveOnMatch *StringMatch `json:"removeOnMatch,omitempty"` | ||
| } | ||
|
|
||
| // HTTPHeaderWrite defines a header to write and how it should be applied when a | ||
| // header with the same name already exists. It mirrors Envoy's | ||
| // core.v3.HeaderValueOption. | ||
| type HTTPHeaderWrite struct { | ||
| // Header is the header name and value to write. | ||
| Header gwapiv1.HTTPHeader `json:"header"` | ||
|
|
||
| // Action controls how the header value is written when a header with the | ||
| // same name already exists. Defaults to Append. | ||
| // | ||
| // +optional | ||
| // +kubebuilder:default=Append | ||
| Action HeaderWriteAction `json:"action,omitempty"` | ||
|
|
||
| // KeepEmptyValue controls whether a header with an empty value is kept. | ||
| // When unset, an empty value is kept only if the provided value is empty. | ||
| // | ||
| // +optional | ||
| KeepEmptyValue *bool `json:"keepEmptyValue,omitempty"` | ||
| } | ||
|
|
||
| // HeaderWriteAction controls how a header value is written when a header with | ||
| // the same name already exists. The values mirror Envoy's | ||
| // HeaderValueOption.HeaderAppendAction. | ||
| // | ||
| // +kubebuilder:validation:Enum=Append;Overwrite;AddIfAbsent;OverwriteIfExists | ||
| type HeaderWriteAction string | ||
|
|
||
| const ( | ||
| // HeaderWriteAppend appends the value if the header exists, or adds the | ||
| // header otherwise. (Envoy: APPEND_IF_EXISTS_OR_ADD) | ||
| HeaderWriteAppend HeaderWriteAction = "Append" | ||
|
|
||
| // HeaderWriteOverwrite overwrites the value if the header exists, or adds | ||
| // the header otherwise. (Envoy: OVERWRITE_IF_EXISTS_OR_ADD) | ||
| HeaderWriteOverwrite HeaderWriteAction = "Overwrite" | ||
|
|
||
| // HeaderWriteAddIfAbsent adds the header only if it is not already present. | ||
| // (Envoy: ADD_IF_ABSENT) | ||
| HeaderWriteAddIfAbsent HeaderWriteAction = "AddIfAbsent" | ||
|
|
||
| // HeaderWriteOverwriteIfExists overwrites the value only if the header is | ||
| // already present, and does nothing otherwise. (Envoy: OVERWRITE_IF_EXISTS) | ||
| HeaderWriteOverwriteIfExists HeaderWriteAction = "OverwriteIfExists" | ||
| ) | ||
|
|
||
| // LocalObjectKeyReference selects a key from a local object. | ||
| type LocalObjectKeyReference struct { | ||
| // The local object to select from. | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting this up. Before we settle the shape, the two examples seem not justify the API.
Both examples are already covered by the existing API:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, @zhaohuabing . Good point. But note, although we may coalesce multiple values with
,(only for inline headers). It's not means they have completely same semantics to forx: a,bandx: a x: b. Esp after we enabled theenvoy.reloadable_features.match_headers_individually.When I see remove there, I mean to use
removeorremove_on_match. It's very possible for a users to remove a list of headers (like all headers withx-custom-prefix) withremove_on_matchand then add a specific onex-custom-specific.