webhook

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder builds a Webhook.

func NewGenericWebhookManagedBy

func NewGenericWebhookManagedBy(mgr manager.Manager) *Builder

NewGenericWebhookManagedBy returns a new webhook Builder that will be invoked by the provided manager.Manager.

func (*Builder) Complete

func (blder *Builder) Complete(i interface{}) error

Complete builds the webhook. If the given object implements the Mutator interface, a MutatingWebhook will be created. If the given object implements the Validator interface, a ValidatingWebhook will be created.

func (*Builder) For

func (blder *Builder) For(apiType runtime.Object) *Builder

For takes a runtime.Object which should be a CR.

func (*Builder) WithMutatePath added in v1.0.1

func (blder *Builder) WithMutatePath(path string) *Builder

WithMutatePath overrides the mutate path of the webhook

func (*Builder) WithMutatePrefix added in v1.0.1

func (blder *Builder) WithMutatePrefix(prefix string) *Builder

WithMutatePrefix sets a custom prefix for the mutate path of the webhook, default is '/mutate-'

func (*Builder) WithValidatePath added in v1.0.1

func (blder *Builder) WithValidatePath(path string) *Builder

WithValidatePath overrides the validate path of the webhook

func (*Builder) WithValidatePrefix added in v1.0.1

func (blder *Builder) WithValidatePrefix(prefix string) *Builder

WithValidatePrefix sets a custom prefix for the validate path of the webhook, default is '/validate-'

type ClientInjector added in v1.5.1

type ClientInjector interface {
	InjectClient(client.Client) error
}

ClientInjector is used to inject a client.Client into webhook handlers.

type DecoderInjector added in v1.5.1

type DecoderInjector interface {
	InjectDecoder(*admission.Decoder) error
}

DecoderInjector is used to inject an admission.Decoder into webhook handlers.

type InjectedClient added in v1.1.0

type InjectedClient struct {
	Client client.Client
}

InjectedClient holds an injected client.Client

func (*InjectedClient) InjectClient added in v1.1.0

func (i *InjectedClient) InjectClient(client client.Client) error

InjectClient implements the ClientInjector interface.

type InjectedDecoder added in v1.1.0

type InjectedDecoder struct {
	Decoder *admission.Decoder
}

InjectedDecoder holds an injected admission.Decoder

func (*InjectedDecoder) InjectDecoder added in v1.1.0

func (i *InjectedDecoder) InjectDecoder(decoder *admission.Decoder) error

InjectDecoder implements the DecoderInjector interface.

type MutateFunc

type MutateFunc struct {
	MutatingWebhook

	Func func(context.Context, admission.Request, runtime.Object) admission.Response
}

MutateFunc is a functional interface for a generic mutating admission webhook.

func (*MutateFunc) Mutate

Mutate implements the Mutator interface by calling the Func.

type MutatingWebhook

type MutatingWebhook struct {
	InjectedClient
	InjectedDecoder
}

MutatingWebhook is a generic mutating admission webhook.

func (*MutatingWebhook) Mutate

Mutate implements the Mutator interface.

type Mutator

type Mutator interface {
	// Mutate yields a response to a mutating AdmissionRequest.
	Mutate(ctx context.Context, req admission.Request, obj runtime.Object) admission.Response
}

Mutator specifies the interface for a generic mutating webhook.

type ValidateFuncs

ValidateFuncs is a functional interface for a generic validating admission webhook.

func (*ValidateFuncs) ValidateCreate

func (v *ValidateFuncs) ValidateCreate(ctx context.Context, req admission.Request, obj runtime.Object) admission.Response

ValidateCreate implements the Validator interface by calling the CreateFunc.

func (*ValidateFuncs) ValidateDelete

func (v *ValidateFuncs) ValidateDelete(ctx context.Context, req admission.Request, obj runtime.Object) admission.Response

ValidateDelete implements the Validator interface by calling the DeleteFunc.

func (*ValidateFuncs) ValidateUpdate

ValidateUpdate implements the Validator interface by calling the UpdateFunc.

type ValidatingWebhook

type ValidatingWebhook struct {
	InjectedClient
	InjectedDecoder
}

ValidatingWebhook is a generic validating admission webhook.

func (*ValidatingWebhook) ValidateCreate

ValidateCreate implements the Validator interface.

func (*ValidatingWebhook) ValidateDelete

ValidateDelete implements the Validator interface.

func (*ValidatingWebhook) ValidateUpdate

ValidateUpdate implements the Validator interface.

type Validator

type Validator interface {
	// ValidateCreate yields a response to a validating AdmissionRequest with operation set to Create.
	ValidateCreate(ctx context.Context, req admission.Request, obj runtime.Object) admission.Response
	// ValidateUpdate yields a response to a validating AdmissionRequest with operation set to Update.
	ValidateUpdate(ctx context.Context, req admission.Request, obj runtime.Object, oldObj runtime.Object) admission.Response
	// ValidateDelete yields a response to a validating AdmissionRequest with operation set to Delete.
	ValidateDelete(ctx context.Context, req admission.Request, obj runtime.Object) admission.Response
}

Validator specifies the interface for a validating webhook.

Jump to

Keyboard shortcuts

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