⚠️ Allow passing a custom webhook server#2293
⚠️ Allow passing a custom webhook server#2293k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
| elected chan struct{} | ||
|
|
||
| webhookServer *webhook.Server | ||
| webhookServer webhook.Server |
There was a problem hiding this comment.
What are some use cases that require an interface instead?
There was a problem hiding this comment.
Basically anything where the default implementation isn't working. The case I have at hand is that the same binary also generates the certificates, so Start has to wait until they exist.
aaae15c to
fec57a7
Compare
|
|
||
| // DefaultServer is the default implementation used for Server. | ||
| type DefaultServer struct { | ||
| Options Options |
There was a problem hiding this comment.
Wondering if Options should be private given that we also have a constructor (but no strong opinion)
There was a problem hiding this comment.
The reason I left it public is that there are a bunch of tests in the Manager that check some values in there
Currently it is impossible to pass a custom webhook server, because we reference the concrete type rather than an interface. Change this to an interface.
fec57a7 to
91cdd8c
Compare
|
Thx! /lgtm /hold |
|
/hold cancel |
|
@alvaroaleman: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
|
@alvaroaleman What's the plan to be able to configure the default webhook server? The |
|
Not sure if that's what you're trying to do, but I did it like this in Cluster API: https://github.com/kubernetes-sigs/cluster-api/blob/d825a40334ac768405d090ddf8eadb73eced3a6d/main.go#L277-L283 |
|
@sbueringer Yes! That solves the linter issue for me, I think we probably want to update the deprecation notes there though |
Earlier `webhook.Server` was a struct. All the struct fields like `Port`, `CertDir` is being moved to `Options` struct. kubernetes-sigs/controller-runtime#2293
See kubernetes-sigs/controller-runtime#2122 See kubernetes-sigs/controller-runtime#2293 Signed-off-by: Tarun Gupta Akirala <takirala@users.noreply.github.com>
Currently it is impossible to pass a custom webhook server, because we reference the concrete type rather than an interface. Change this to an interface.