-
Notifications
You must be signed in to change notification settings - Fork 104
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
Refactored instance validation webhook #1207
Conversation
Summary: existing `Validator` interface was removed, we're now using the underlying `http.Handler` interface to register webhooks. This reduces glue code and prepares the foundation for upcoming KEP-20 admission webhook which will use the same interface (but will be a mutating instead of validating webhook)
// A client will be automatically injected. | ||
|
||
// InjectClient injects the client. | ||
func (v *InstanceValidator) InjectClient(c client.Client) error { |
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.
Strictly speaking, this webhook doesn't need the client
but I intend for this webhook to be a template for future ones so I kept it here.
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.
LGTM
// registerWebhook method registers passed webhook using a give prefix (e.g. "/validate") and runtime object | ||
// (e.g. v1beta1.Instance) to generate a webhook path e.g. "/validate-kudo-dev-v1beta1-instances". Webhook | ||
// has to implement http.Handler interface (see v1beta1.InstanceValidator for an example) | ||
func registerWebhook(prefix string, obj runtime.Object, hook http.Handler, mgr manager.Manager) error { |
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.
even nicer would be to have a webhook type that would then map to this prefix :) but we can improve on that :)
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.
yep. let's see what abstractions will prove themselves useful once we add more hooks.
Summary: existing `Validator` interface was removed, we're now using the underlying `http.Handler` interface to register webhooks. This reduces glue code and prepares the foundation for upcoming KEP-20 admission webhook which will use the same interface (but will be a mutating instead of validating webhook) (cherry picked from commit 366222d)
* Refactored instance validation webhook (#1207) Summary: existing `Validator` interface was removed, we're now using the underlying `http.Handler` interface to register webhooks. This reduces glue code and prepares the foundation for upcoming KEP-20 admission webhook which will use the same interface (but will be a mutating instead of validating webhook) (cherry picked from commit 366222d) * Reintroduce 366222d (#1207) Additionally: - excluded `instance_validator.go` from code generation - and fixed an erroneous client import
Summary: existing `Validator` interface was removed, we're now using the underlying `http.Handler` interface to register webhooks. This reduces glue code and prepares the foundation for upcoming KEP-20 admission webhook which will use the same interface (but will be a mutating instead of validating webhook) Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
* Refactored instance validation webhook (#1207) Summary: existing `Validator` interface was removed, we're now using the underlying `http.Handler` interface to register webhooks. This reduces glue code and prepares the foundation for upcoming KEP-20 admission webhook which will use the same interface (but will be a mutating instead of validating webhook) (cherry picked from commit 366222d) * Reintroduce 366222d (#1207) Additionally: - excluded `instance_validator.go` from code generation - and fixed an erroneous client import Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Summary:
existing
Validator
interface was removed, we're now using the underlyinghttp.Handler
interface to implement webhooks. This reduces glue code and prepares the foundation for upcoming KEP-20 admission webhook which will use the same interface (but will be a mutating instead of validating webhook)