Documentation ¶
Index ¶
- func Mutating(factory AdmissionHandlerType) configuration
- func NewAdmissionRegistration(resources resources.ResourcesSource, spec interface{}, ...) (*adminreg.RuleWithOperations, error)
- func NewAdmissionSpecData(resources resources.ResourcesSource, policy adminreg.FailurePolicyType, ...) ([]adminreg.RuleWithOperations, *adminreg.FailurePolicyType, error)
- func Validating(factory AdmissionHandlerType) configuration
- type AdmissionHandlerType
- type Decoder
- type DefaultHandler
- type Definition
- type HTTPHandler
- type Interface
- type MutatingWebhookDeclaration
- type Request
- type Response
- func Allowed(reason string) Response
- func Denied(reason string) Response
- func ErrorResponse(code int32, err error) Response
- func PatchResponseFromRaw(original, current []byte) Response
- func Patched(reason string, patches ...jsonpatch.JsonPatchOperation) Response
- func ValidationResponse(allowed bool, reason string) Response
- type ValidatingWebhookDeclaration
- type WebhookFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Mutating ¶
func Mutating(factory AdmissionHandlerType) configuration
func NewAdmissionRegistration ¶
func NewAdmissionRegistration(resources resources.ResourcesSource, spec interface{}, ops ...adminreg.OperationType) (*adminreg.RuleWithOperations, error)
func NewAdmissionSpecData ¶
func NewAdmissionSpecData(resources resources.ResourcesSource, policy adminreg.FailurePolicyType, ops []adminreg.OperationType, rkeys ...extension.ResourceKey) ([]adminreg.RuleWithOperations, *adminreg.FailurePolicyType, error)
func Validating ¶
func Validating(factory AdmissionHandlerType) configuration
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder knows how to decode the contents of an admission request into a concrete object.
func NewDecoder ¶
NewDecoder creates a Decoder given the runtime.Scheme
type DefaultHandler ¶
type DefaultHandler struct { }
DefaultHandler can be used for a default implementation of all interface methods
func (*DefaultHandler) Handle ¶
func (this *DefaultHandler) Handle(logger.LogContext, Request) Response
type Definition ¶
type Definition interface { GetKind() webhook.WebhookKind GetHTTPHandler(wh webhook.Interface) (http.Handler, error) GetNamespaces() *meta.LabelSelector GetOperations() []adminreg.OperationType GetFailurePolicy() adminreg.FailurePolicyType }
type HTTPHandler ¶
type HTTPHandler struct { logger.LogContext // contains filtered or unexported fields }
HTTPHandler represents each individual webhook.
func (*HTTPHandler) ServeHTTP ¶
func (this *HTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*HTTPHandler) Webhook ¶
func (this *HTTPHandler) Webhook() Interface
type Interface ¶
type Interface interface {
Handle(logger.LogContext, Request) Response
}
Interface can handle an AdmissionRequest.
type MutatingWebhookDeclaration ¶
type MutatingWebhookDeclaration struct {
adminreg.MutatingWebhook
}
func (*MutatingWebhookDeclaration) DeepCopy ¶
func (this *MutatingWebhookDeclaration) DeepCopy() *adminreg.MutatingWebhook
func (*MutatingWebhookDeclaration) Kind ¶
func (this *MutatingWebhookDeclaration) Kind() webhook.WebhookKind
type Request ¶
type Request struct {
admissionv1beta1.AdmissionRequest
}
Request defines the input for an admission handler. It contains information to identify the object in question (group, version, kind, resource, subresource, name, namespace), as well as the operation in question (e.g. Get, Create, etc), and the object itself.
type Response ¶
type Response struct { // Patches are the JSON patches for mutating webhooks. // Using this instead of setting Response.Patch to minimize // overhead of serialization and deserialization. // Patches set here will override any patches in the response, // so leave this empty if you want to set the patch response directly. Patches []jsonpatch.JsonPatchOperation // AdmissionResponse is the raw admission response. // The Patch field in it will be overwritten by the listed patches. admissionv1beta1.AdmissionResponse }
Response is the output of an admission handler. It contains a response indicating if a given operation is allowed, as well as a set of patches to mutate the object in the case of a mutating admission handler.
func Allowed ¶
Allowed constructs a response indicating that the given operation is allowed (without any patches).
func ErrorResponse ¶
ErrorResponse creates a new Response for error-handling a request.
func PatchResponseFromRaw ¶
PatchResponseFromRaw takes 2 byte arrays and returns a new response with json patch. The original object should be passed in as raw bytes to avoid the roundtripping problem described in https://github.com/kubernetes-sigs/kubebuilder/issues/510.
func Patched ¶
func Patched(reason string, patches ...jsonpatch.JsonPatchOperation) Response
Patched constructs a response indicating that the given operation is allowed, and that the target object should be modified by the given JSONPatch operations.
func ValidationResponse ¶
ValidationResponse returns a response for admitting a request.
type ValidatingWebhookDeclaration ¶
type ValidatingWebhookDeclaration struct {
adminreg.ValidatingWebhook
}
func (*ValidatingWebhookDeclaration) DeepCopy ¶
func (this *ValidatingWebhookDeclaration) DeepCopy() *adminreg.ValidatingWebhook
func (*ValidatingWebhookDeclaration) Kind ¶
func (this *ValidatingWebhookDeclaration) Kind() webhook.WebhookKind
type WebhookFunc ¶
type WebhookFunc func(logger.LogContext, Request) Response
WebhookFunc implements Handler interface using a single function.
func (WebhookFunc) Handle ¶
func (this WebhookFunc) Handle(logger logger.LogContext, req Request) Response
Handle process the AdmissionRequest by invoking the underlying function.
func (WebhookFunc) Type ¶
func (this WebhookFunc) Type() AdmissionHandlerType