Documentation ¶
Overview ¶
Package validation allows a caller to automatically register, lookup and call API validation functions. It is similar to runtime.Scheme and is designed to make writing and consuming API validation functions easier.
Index ¶
- type Registry
- func (r *Registry) AddValidateFunc(obj runtime.Object, fn ValidateFunc) error
- func (r *Registry) AddValidateUpdateFunc(obj runtime.Object, fn ValidateUpdateFunc) error
- func (r *Registry) Validate(req *admissionv1.AdmissionRequest, obj runtime.Object, ...) field.ErrorList
- func (r *Registry) ValidateUpdate(req *admissionv1.AdmissionRequest, oldObj, obj runtime.Object, ...) field.ErrorList
- type ValidateFunc
- type ValidateUpdateFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is used to store and lookup references to validation functions for given Kubernetes API types.
func NewRegistry ¶
NewRegistry creates a new empty registry, backed by the provided Scheme.
func (*Registry) AddValidateFunc ¶
func (r *Registry) AddValidateFunc(obj runtime.Object, fn ValidateFunc) error
AddValidateFunc will add a new validation function to the register. The function will be run whenever Validate is called with a requestVersion set to any recognised GroupVersionKinds for this object. If obj is part of an internal API version, the validation function will be called on all calls to Validate regardless of version. If obj cannot be recognised using the registry's scheme, an error will be returned.
func (*Registry) AddValidateUpdateFunc ¶
func (r *Registry) AddValidateUpdateFunc(obj runtime.Object, fn ValidateUpdateFunc) error
AddValidateUpdateFunc will add a new validation function to the register. The function will be run whenever ValidateUpdate is called with a requestVersion set to any recognised GroupVersionKinds for this object. If obj is part of an internal API version, the validation function will be called on all calls to Validate regardless of version. If obj cannot be recognised using the registry's scheme, an error will be returned.
func (*Registry) Validate ¶
func (r *Registry) Validate(req *admissionv1.AdmissionRequest, obj runtime.Object, requestVersion schema.GroupVersionKind) field.ErrorList
Validate will run all validation functions registered for the given object. If the passed obj is *not* of the same version as the provided requestVersion, the registry will attempt to convert the object before calling the validation functions. Any validation functions registered for the objects internal API version will be run against the object regardless of version.
func (*Registry) ValidateUpdate ¶
func (r *Registry) ValidateUpdate(req *admissionv1.AdmissionRequest, oldObj, obj runtime.Object, requestVersion schema.GroupVersionKind) field.ErrorList
ValidateUpdate will run all update validation functions registered for the given object. If the passed objects are *not* of the same version as the provided requestVersion, the registry will attempt to convert the objects before calling the validation functions. Any validation functions registered for the objects internal API version will be run against the object regardless of version.
type ValidateFunc ¶
type ValidateFunc func(req *admissionv1.AdmissionRequest, obj runtime.Object) field.ErrorList
type ValidateUpdateFunc ¶
type ValidateUpdateFunc func(req *admissionv1.AdmissionRequest, oldObj, obj runtime.Object) field.ErrorList