admission

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdmissionRequest

func AdmissionRequest(ctx context.Context) admission.Request

AdmissionRequest returns admission request from context

func DefaultingWebhookFor

func DefaultingWebhookFor(ctx context.Context, defaulter Defaulter, transforms ...TransformFunc) *admission.Webhook

DefaultingWebhookFor creates a new Webhook for Defaulting the provided type.

func RegisterDefaultWebhookFor

func RegisterDefaultWebhookFor(ctx context.Context, mgr ctrl.Manager, defaulter Defaulter, transforms ...TransformFunc) (err error)

RegisterDefaultWebhookFor registers a mutate webhook for the defaulter with transforms

func RegisterValidateWebhookFor added in v0.3.0

func RegisterValidateWebhookFor(ctx context.Context, mgr ctrl.Manager, validator Validator, validateCreateFuncs []ValidateCreateFunc, validateUpdateFuncs []ValidateUpdateFunc, validateDeleteFuncs []ValidateDeleteFunc) (err error)

RegisterValidateWebhookFor registers a mutate webhook for the defaulter with transforms

func SubjectFromRequest

func SubjectFromRequest(req admission.Request) *rbacv1.Subject

returns a user based on the request information

func ValidatingWebhookFor added in v0.3.0

func ValidatingWebhookFor(ctx context.Context, validator Validator, creates []ValidateCreateFunc, updates []ValidateUpdateFunc, deletes []ValidateDeleteFunc) *admission.Webhook

ValidatingWebhookFor creates a new Webhook for Validating the provided type.

func WithAdmissionRequest

func WithAdmissionRequest(ctx context.Context, req admission.Request) context.Context

WithAdmissionRequest adds an admission request to the context

Types

type Defaulter

type Defaulter interface {
	runtime.Object
	metav1.Object
	Default(context.Context)
}

Defaulter defines functions for setting defaults on resources

type DefaulterWebhook added in v0.2.0

type DefaulterWebhook interface {
	Defaulter
	sharedmain.WebhookSetup
	sharedmain.WebhookRegisterSetup
	WithTransformer(transformers ...TransformFunc) DefaulterWebhook
	WithLoggerName(loggerName string) DefaulterWebhook
}

func NewDefaulterWebhook added in v0.2.0

func NewDefaulterWebhook(defaulter Defaulter) DefaulterWebhook

type TransformFunc

type TransformFunc func(context.Context, runtime.Object, admission.Request)

TransformFuncused to make common defaulting logic amongst multiple resource using a context, an object and a request

func WithCreatedBy added in v0.2.0

func WithCreatedBy() TransformFunc

WithCreatedBy adds a createdBy annotation to the object using the request information when an object already has the createdBy annotation it will only increment missing data

func WithTriggeredBy

func WithTriggeredBy() TransformFunc

WithTriggeredBy adds a triggeredBy annotation to the object using the request information when an object already has the triggeredBy annotation it will only increment missing data

type ValidateCreateFunc added in v0.3.0

type ValidateCreateFunc func(ctx context.Context, obj runtime.Object, req admission.Request) error

ValidateCreateFunc function to add validation functions when operation is create using a context, an object and a request

type ValidateDeleteFunc added in v0.3.0

type ValidateDeleteFunc func(ctx context.Context, obj runtime.Object, req admission.Request) error

ValidateDeleteFunc function to add validation functions when operation is delete using a context, an object and a request

type ValidateUpdateFunc added in v0.3.0

type ValidateUpdateFunc func(ctx context.Context, obj runtime.Object, old runtime.Object, req admission.Request) error

ValidateUpdateFunc function to add validation functions when operation is update using a context, the current object, the old object and a request

type Validator added in v0.3.0

type Validator interface {
	runtime.Object
	metav1.Object
	ValidateCreate(ctx context.Context) error
	ValidateUpdate(ctx context.Context, old runtime.Object) error
	ValidateDelete(ctx context.Context) error
}

Validator defines functions for validating an operation

type ValidatorWebhook added in v0.3.0

type ValidatorWebhook interface {
	Validator
	sharedmain.WebhookSetup
	sharedmain.WebhookRegisterSetup
	WithValidateCreate(creates ...ValidateCreateFunc) ValidatorWebhook
	WithValidateUpdate(updates ...ValidateUpdateFunc) ValidatorWebhook
	WithValidateDelete(deletes ...ValidateDeleteFunc) ValidatorWebhook
	WithLoggerName(loggerName string) ValidatorWebhook
}

func NewValidatorWebhook added in v0.3.0

func NewValidatorWebhook(validator Validator) ValidatorWebhook

Jump to

Keyboard shortcuts

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