-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
✨ Pass HTTP request Context through to admission Webhook handlers #549
✨ Pass HTTP request Context through to admission Webhook handlers #549
Conversation
Welcome @seh! |
25dad67
to
402d93e
Compare
good catch, thanks! /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: DirectXMan12, seh The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
// Handle yields a response to an AdmissionRequest. | ||
// | ||
// The supplied context is extracted from the received http.Request, allowing wrapping | ||
// http.Handlers to inject values into and control cancelation of downstream request processing. |
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.
In proxy server terms, the inner handlers are analogous to "upstream" servers. Given that, if my use of "downstream" is confusing, please let me know and I can try again.
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.
eh, I think it's clear enough if you're vaguely familiar with context. We'll see if anyone complains :-)
Rather than synthesizing a fresh
context.Context
for each admission Webhook request, instead pass through aContext
obtained from the originalhttp.Request
passed in to thehttp.Handler
. This way, we can wrap middlewarehttp.Handler
s around thewebhook.Admission
handlers, such as those that establish tracing spans, instrumentation, or logging context, and have ouradmission.Handler
s continue to use that same context.Note that if an
http.Request
had noContext
bound explicitly withhttp.WithContext
, theRequest.Context
method returnscontext.Background
.