admission

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2020 License: Apache-2.0, MIT Imports: 21 Imported by: 0

Documentation

Index

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 Validating

func Validating(factory AdmissionHandlerType) configuration

Types

type AdmissionHandlerType

type AdmissionHandlerType func(wh webhook.Interface) (Interface, error)

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

func NewDecoder(scheme *runtime.Scheme) *Decoder

NewDecoder creates a Decoder given the runtime.Scheme

func (*Decoder) Decode

func (d *Decoder) Decode(req Request, into runtime.Object) error

Decode decodes the inlined object in the AdmissionRequest into the passed-in runtime.Object. If you want decode the OldObject in the AdmissionRequest, use DecodeRaw.

func (*Decoder) DecodeRaw

func (d *Decoder) DecodeRaw(rawObj runtime.RawExtension, into runtime.Object) error

DecodeRaw decodes a RawExtension object into the passed-in runtime.Object.

type DefaultHandler

type DefaultHandler struct {
}

DefaultHandler can be used for a default implementation of all interface methods

func (*DefaultHandler) Handle

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 (*MutatingWebhookDeclaration) Kind

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

func Allowed(reason string) Response

Allowed constructs a response indicating that the given operation is allowed (without any patches).

func Denied

func Denied(reason string) Response

Denied constructs a response indicating that the given operation is not allowed.

func ErrorResponse

func ErrorResponse(code int32, err error) Response

ErrorResponse creates a new Response for error-handling a request.

func PatchResponseFromRaw

func PatchResponseFromRaw(original, current []byte) Response

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

func ValidationResponse(allowed bool, reason string) Response

ValidationResponse returns a response for admitting a request.

func (*Response) Complete

func (this *Response) Complete(req Request) error

Complete populates any fields that are yet to be set in the underlying AdmissionResponse, It mutates the response.

type ValidatingWebhookDeclaration

type ValidatingWebhookDeclaration struct {
	adminreg.ValidatingWebhook
}

func (*ValidatingWebhookDeclaration) DeepCopy

func (*ValidatingWebhookDeclaration) Kind

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL