webhook

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package webhook contains utilities for building Kubernetes webhooks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MutateFn

type MutateFn func(ctx context.Context, obj runtime.Object) error

MutateFn is a single mutating function that can be used by Mutator.

type Mutator

type Mutator struct {
	MutationChain []MutateFn
}

Mutator satisfies CustomDefaulter interface with an ordered MutateFn list.

func NewMutator

func NewMutator(opts ...MutatorOption) *Mutator

NewMutator returns a new instance of Mutator that can be used as CustomDefaulter.

func (*Mutator) Default

func (m *Mutator) Default(ctx context.Context, obj runtime.Object) error

Default executes the MutatorFns in given order. Its name might sound misleading since defaulting seems to be the first use case used by controller-runtime but MutatorFns can make any changes on given resource.

type MutatorOption

type MutatorOption func(*Mutator)

MutatorOption configures given Mutator.

func WithMutationFns

func WithMutationFns(fns ...MutateFn) MutatorOption

WithMutationFns allows you to initiate the mutator with given list of mutator functions.

type ValidateCreateFn

type ValidateCreateFn func(ctx context.Context, obj runtime.Object) error

ValidateCreateFn is function type for creation validation.

type ValidateDeleteFn

type ValidateDeleteFn func(ctx context.Context, obj runtime.Object) error

ValidateDeleteFn is function type for deletion validation.

type ValidateUpdateFn

type ValidateUpdateFn func(ctx context.Context, oldObj, newObj runtime.Object) error

ValidateUpdateFn is function type for update validation.

type Validator

type Validator struct {
	CreationChain []ValidateCreateFn
	UpdateChain   []ValidateUpdateFn
	DeletionChain []ValidateDeleteFn
}

Validator runs the given validation chains in order.

func NewValidator

func NewValidator(opts ...ValidatorOption) *Validator

NewValidator returns a new Validator with no-op defaults.

func (*Validator) ValidateCreate

func (vc *Validator) ValidateCreate(ctx context.Context, obj runtime.Object) error

ValidateCreate runs functions in creation chain in order.

func (*Validator) ValidateDelete

func (vc *Validator) ValidateDelete(ctx context.Context, obj runtime.Object) error

ValidateDelete runs functions in deletion chain in order.

func (*Validator) ValidateUpdate

func (vc *Validator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) error

ValidateUpdate runs functions in update chain in order.

type ValidatorOption

type ValidatorOption func(*Validator)

ValidatorOption allows you to configure given Validator.

func WithValidateCreationFns

func WithValidateCreationFns(fns ...ValidateCreateFn) ValidatorOption

WithValidateCreationFns initializes the Validator with given set of creation validation functions.

func WithValidateDeletionFns

func WithValidateDeletionFns(fns ...ValidateDeleteFn) ValidatorOption

WithValidateDeletionFns initializes the Validator with given set of deletion validation functions.

func WithValidateUpdateFns

func WithValidateUpdateFns(fns ...ValidateUpdateFn) ValidatorOption

WithValidateUpdateFns initializes the Validator with given set of update validation functions.

Jump to

Keyboard shortcuts

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