cert-manager: github.com/jetstack/cert-manager/pkg/internal/api/validation Index | Files

package validation

import "github.com/jetstack/cert-manager/pkg/internal/api/validation"

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

Package Files

registry.go

type Registry Uses

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 Uses

func NewRegistry(scheme *runtime.Scheme) *Registry

NewRegistry creates a new empty registry, backed by the provided Scheme.

func (*Registry) AddValidateFunc Uses

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 Uses

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 Uses

func (r *Registry) Validate(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 Uses

func (r *Registry) ValidateUpdate(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 Uses

type ValidateFunc func(obj runtime.Object) field.ErrorList

type ValidateUpdateFunc Uses

type ValidateUpdateFunc func(oldObj, obj runtime.Object) field.ErrorList

Package validation imports 3 packages (graph) and is imported by 8 packages. Updated 2020-01-21. Refresh now. Tools for package owners.