Skip to content
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

api: adds request/response attributes ExtProc options #4496

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions api/v1alpha1/ext_proc_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,18 @@ type ExtProc struct {
//
// +optional
ProcessingMode *ExtProcProcessingMode `json:"processingMode,omitempty"`

// RequestAttributes is a list of request attributes that should be sent to the external processor
// on the request_headers message. The possible attributes are defined in the envoy documentation:
// https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/advanced/attributes#arch-overview-attributes
//
// +optional
RequestAttributes []string `json:"requestAttributes,omitempty"`

// ResponseAttributes is a list of response attributes that should be sent to the external processor
// on the response_headers message. The possible attributes are defined in the envoy documentation:
// https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/advanced/attributes#arch-overview-attributes
//
// +optional
ResponseAttributes []string `json:"responseAttributes,omitempty"`
}
10 changes: 10 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,22 @@ spec:
type: string
type: object
type: object
requestAttributes:
description: |-
RequestAttributes is a list of request attributes that should be sent to the external processor
on the request_headers message. The possible attributes are defined in the envoy documentation:
https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/advanced/attributes#arch-overview-attributes
items:
type: string
type: array
responseAttributes:
description: |-
ResponseAttributes is a list of response attributes that should be sent to the external processor
on the response_headers message. The possible attributes are defined in the envoy documentation:
https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/advanced/attributes#arch-overview-attributes
items:
type: string
type: array
type: object
x-kubernetes-validations:
- message: BackendRefs must be used, backendRef is not supported.
Expand Down
8 changes: 8 additions & 0 deletions internal/gatewayapi/envoyextensionpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,14 @@ func (t *Translator) buildExtProc(
}
}

if extProc.RequestAttributes != nil {
extProcIR.RequestAttributes = extProc.RequestAttributes
}

if extProc.ResponseAttributes != nil {
extProcIR.ResponseAttributes = extProc.ResponseAttributes
}

return extProcIR, err
}

Expand Down
6 changes: 6 additions & 0 deletions internal/ir/xds.go
Original file line number Diff line number Diff line change
Expand Up @@ -2546,6 +2546,12 @@ type ExtProc struct {

// ResponseBodyProcessingMode Defines response body processing
ResponseBodyProcessingMode *ExtProcBodyProcessingMode `json:"responseBodyProcessingMode,omitempty" yaml:"responseBodyProcessingMode,omitempty"`

// RequestAttributes defines the attributes to be sent to the external processor
RequestAttributes []string `json:"requestAttributes,omitempty" yaml:"requestAttributes,omitempty"`

// ResponseAttributes defines the attributes to be sent to the external processor
ResponseAttributes []string `json:"responseAttributes,omitempty" yaml:"responseAttributes,omitempty"`
}

// Wasm holds the information associated with the Wasm extensions.
Expand Down
10 changes: 10 additions & 0 deletions internal/ir/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions internal/xds/translator/extproc.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ func extProcConfig(extProc ir.ExtProc) *extprocv3.ExternalProcessor {
config.ProcessingMode.ResponseHeaderMode = extprocv3.ProcessingMode_SEND
}

if extProc.RequestAttributes != nil {
config.RequestAttributes = extProc.RequestAttributes
}

if extProc.ResponseAttributes != nil {
config.ResponseAttributes = extProc.ResponseAttributes
}

return config
}

Expand Down
2 changes: 2 additions & 0 deletions test/cel-validation/envoyextensionpolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ func TestEnvoyExtensionPolicyTarget(t *testing.T) {
},
},
},
RequestAttributes: []string{"request.path"},
ResponseAttributes: []string{"response.code"},
Comment on lines +296 to +297
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this is the enough testing 😉

},
},
PolicyTargetReferences: egv1a1.PolicyTargetReferences{
Expand Down
Loading