Documentation
¶
Overview ¶
Package admission contains functions to add and retrieve admission request from context
Index ¶
- func AdmissionRequest(ctx context.Context) admission.Request
- func DefaultingWebhookFor(ctx context.Context, defaulter Defaulter, transforms ...TransformFunc) *admission.Webhook
- func RegisterDefaultWebhookFor(ctx context.Context, mgr ctrl.Manager, defaulter Defaulter, ...) (err error)
- func RegisterValidateWebhookFor(ctx context.Context, mgr ctrl.Manager, validator Validator, ...) (err error)
- func SubjectFromRequest(req admission.Request) *rbacv1.Subject
- func ValidatingWebhookFor(ctx context.Context, validator Validator, creates []ValidateCreateFunc, ...) *admission.Webhook
- func WithAdmissionRequest(ctx context.Context, req admission.Request) context.Context
- type ContextInjector
- type Defaulter
- type DefaulterWebhook
- type TransformFunc
- type ValidateCreateFunc
- type ValidateDeleteFunc
- type ValidateUpdateFunc
- type Validator
- type ValidatorWebhook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdmissionRequest ¶
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 ¶
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 ¶
SubjectFromRequest returns a user based on the request information
func ValidatingWebhookFor ¶
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.
Types ¶
type ContextInjector ¶
ContextInjector define function to inject context, such as logger, k8s client etc.
type DefaulterWebhook ¶
type DefaulterWebhook interface {
Defaulter
sharedmain.WebhookSetup
sharedmain.WebhookRegisterSetup
WithTransformer(transformers ...TransformFunc) DefaulterWebhook
WithLoggerName(loggerName string) DefaulterWebhook
}
func NewDefaulterWebhook ¶
func NewDefaulterWebhook(defaulter Defaulter) DefaulterWebhook
type TransformFunc ¶
TransformFunc used to make common defaulting logic amongst multiple resource using a context, an object and a request
func WithCreatedBy ¶
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 WithUpdateTime ¶
func WithUpdateTime() TransformFunc
WithUpdateTime adds a updateTime annotation to the object
func WithUpdatedBy ¶
func WithUpdatedBy() TransformFunc
WithUpdatedBy adds a updatedBy annotation to the object using the request information when an object already has the updatedBy annotation it will cover old data
type ValidateCreateFunc ¶
ValidateCreateFunc function to add validation functions when operation is create using a context, an object and a request
type ValidateDeleteFunc ¶
ValidateDeleteFunc function to add validation functions when operation is delete using a context, an object and a request
type ValidateUpdateFunc ¶
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 ¶
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 ¶
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 ¶
func NewValidatorWebhook(validator Validator) ValidatorWebhook