Documentation ¶
Overview ¶
Package admission provides interfaces for building admission controllers with chaining function with support for both k8s native and custom resources in a consistent way. It's based on the custom resource admission webhook from controller-runtime, modified to not be specific to custom resources only. The defaulter and validator can have multiple functions, chained together to form a processing pipeline. They also have the ability to perform checks in advance before passing the object to the processing pipeline to avoid repetitive checks in each of the functions for filtering the objects and ignoring if needed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultingWebhookFor ¶
DefaultingWebhookFor creates a new webhook for Defaulting the provided object type.
func ValidatingWebhookFor ¶
ValidatingWebhookFor creates a new Webhook for validating the provided object type.
Types ¶
type Controller ¶
type Controller interface { // Name returns the name of the controller. Name() string Defaulter Validator }
Controller defines an interface for a webhook admission controller.
type DefaultFunc ¶
DefaultFunc is a function in the defaulting function chain, which forms a defaulter pipeline.
type Defaulter ¶
type Defaulter interface { // ObjectGetter returns a new instance of the target object type of the // defaulter. ObjectGetter // Default returns a list of default functions that form the defaulting // pipeline. Default() []DefaultFunc // RequireDefaulting can be used to perform a check before processing the // request object and decide if defaulting is required or the object can be // ignore. Default() will not be called if this returns false. In case of // any error, true can be returned and a similar check can be performed in // a defaulting function that can return the proper error message that'll // be propagated to the user. RequireDefaulting(obj client.Object) bool }
Defaulter defines functions for setting defaults on resource.
type ObjectGetter ¶
type ObjectGetter interface { // GetNewObject returns a new initialized object of the target object type. GetNewObject() client.Object }
ObjectGetter defines an interface for getting an object of any type, depending on the controller's target object type, in a generic form.
type ValidateCreateFunc ¶
Validate-Funcs are functions in validating function chain, which forms a validating pipeline for a type of operation.
type ValidateDeleteFunc ¶
type ValidateUpdateFunc ¶
type Validator ¶
type Validator interface { // ObjectGetter returns a new instance of the target object type of the // defaulter. ObjectGetter // ValidateCreate returns a list of validate functions for create event. ValidateCreate() []ValidateCreateFunc // ValidateCreate returns a list of validate functions for update event. ValidateUpdate() []ValidateUpdateFunc // ValidateCreate returns a list of validate functions for delete event. ValidateDelete() []ValidateDeleteFunc // RequireValidating can be used to perform a check before processing the // request object and decide if validating is required or the object can be // ignored. None of the validating functions will be called if this returns // false. In case of any error, true can be returned and a similar check // can be performed in a validate function that can return the proper error // message that'll be propogated to the user. RequireValidating(obj client.Object) bool }
Validator defines functions for validating an operation.