validation

package
v1.2.0-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

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

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL