Back to godoc.org

Package validation

v0.16.1
Latest Go to latest

The latest major version is .

Published: Aug 7, 2020 | License: Apache-2.0 | Module: github.com/jetstack/cert-manager

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

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

func NewRegistry(scheme *runtime.Scheme) *Registry

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(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(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(obj runtime.Object) field.ErrorList

type ValidateUpdateFunc

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

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier