validation

package
v0.36.0-flux.11 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collector

type Collector struct {
	Errors     []error
	InvalidIds object.ObjMetadataSet
}

Collector simplifies collecting validation errors from multiple sources and extracting the IDs of the invalid objects.

func (*Collector) Collect

func (c *Collector) Collect(err error)

Collect unwraps MultiErrors, adds them to Errors, extracts invalid object IDs from validation.Error, and adds them to InvalidIds.

func (*Collector) FilterInvalidIds

func (c *Collector) FilterInvalidIds(ids object.ObjMetadataSet) object.ObjMetadataSet

FilterInvalidIds returns a set of object ID that does not contain any invalid IDs, based on the collected InvalidIds.

func (*Collector) FilterInvalidObjects

func (c *Collector) FilterInvalidObjects(objs object.UnstructuredSet) object.UnstructuredSet

FilterInvalidObjects returns a set of objects that does not contain any invalid objects, based on the collected InvalidIds.

func (*Collector) ToError

func (c *Collector) ToError() error

ToError returns the list of errors as a single error.

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error wraps an error with the object or objects it applies to.

func NewError

func NewError(cause error, ids ...object.ObjMetadata) *Error

func (*Error) Error

func (ve *Error) Error() string

Error stringifies the the error.

func (*Error) Identifiers

func (ve *Error) Identifiers() object.ObjMetadataSet

Identifiers returns zero or more object IDs which are invalid.

func (*Error) Unwrap

func (ve *Error) Unwrap() error

Unwrap returns the cause of the error. This may be useful when printing the cause without printing the identifiers.

type Policy

type Policy int
const (
	// ExitEarly policy errors and exits if any objects are invalid, before
	// apply/delete of any objects.
	ExitEarly Policy = iota

	// SkipInvalid policy skips the apply/delete of invalid objects.
	SkipInvalid
)

func (Policy) String

func (i Policy) String() string

type Validator

type Validator struct {
	Mapper    meta.RESTMapper
	Collector *Collector
}

Validator contains functionality for validating a set of resources prior to being used by the Apply functionality. This imposes some constraint not always required, such as namespaced resources must have the namespace set.

func (*Validator) Validate

func (v *Validator) Validate(objs []*unstructured.Unstructured)

Validate validates the provided resources. A RESTMapper will be used to fetch type information from the live cluster.

Jump to

Keyboard shortcuts

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