validate

package
v0.0.0-...-12b77bc Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DomainRegexp defines the structure of potential domain components
	// that may be part of image names. This is purposely a subset of what is
	// allowed by DNS to ensure backwards compatibility with Docker image
	// names.
	DomainRegexp = expression(
		domainComponentRegexp,
		optional(repeated(literal(`.`), domainComponentRegexp)),
		optional(literal(`:`), match(`[0-9]+`)))

	// TagRegexp matches valid tag names. From docker/docker:graph/tags.go.
	TagRegexp = match(`[\w][\w.-]{0,127}`)

	// DigestRegexp matches valid digests.
	DigestRegexp = match(`[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][[:xdigit:]]{32,}`)

	// NameRegexp is the format for the name component of references. The
	// regexp has capturing groups for the domain and name part omitting
	// the separating forward slash from either.
	NameRegexp = expression(
		optional(DomainRegexp, literal(`/`)),
		nameComponentRegexp,
		optional(repeated(literal(`/`), nameComponentRegexp)))

	// ReferenceRegexp is the full supported format of a reference. The regexp
	// is anchored and has capturing groups for name, tag, and digest
	// components.
	ReferenceRegexp = anchored(capture(NameRegexp),
		optional(literal(":"), capture(TagRegexp)),
		optional(literal("@"), capture(DigestRegexp)))

	// ObjectNameRegexp is a legal name for a k8s object.
	ObjectNameRegexp = match(`[a-z0-9.-]{1,254}`)
)
View Source
var (
	// DefaultValidations maps a data path to a validation function.
	DefaultValidations = map[string]ValidatorFunc{
		"Values": func(path util.Path, i any) util.Errors {
			return CheckValues(i)
		},
		"MeshConfig":                 validateMeshConfig,
		"Hub":                        validateHub,
		"Tag":                        validateTag,
		"Revision":                   validateRevision,
		"Components.IngressGateways": validateGatewayName,
		"Components.EgressGateways":  validateGatewayName,
	}
)
View Source
var DefaultValuesValidations = map[string]ValidatorFunc{
	"global.proxy.includeIPRanges":     validateIPRangesOrStar,
	"global.proxy.excludeIPRanges":     validateIPRangesOrStar,
	"global.proxy.includeInboundPorts": validateStringList(validatePortNumberString),
	"global.proxy.excludeInboundPorts": validateStringList(validatePortNumberString),
	"meshConfig":                       validateMeshConfig,
}

DefaultValuesValidations maps a data path to a validation function.

Functions

func CheckIstioOperator

func CheckIstioOperator(iop *operator_v1alpha1.IstioOperator, checkRequiredFields bool) error

CheckIstioOperator validates the operator CR.

func CheckIstioOperatorSpec

func CheckIstioOperatorSpec(is *v1alpha1.IstioOperatorSpec, checkRequiredFields bool) (errs util.Errors)

CheckIstioOperatorSpec validates the values in the given Installer spec, using the field map DefaultValidations to call the appropriate validation function. checkRequiredFields determines whether missing mandatory fields generate errors.

func CheckValues

func CheckValues(root any) util.Errors

CheckValues validates the values in the given tree, which follows the Istio values.yaml schema.

func UnmarshalIOP

func UnmarshalIOP(iopYAML string) (*v1alpha1.IstioOperator, error)

UnmarshalIOP unmarshals a string containing IstioOperator as YAML.

func ValidIOP

func ValidIOP(iop *v1alpha1.IstioOperator) error

ValidIOP validates the given IstioOperator object.

func Validate

func Validate(validations map[string]ValidatorFunc, structPtr any, path util.Path, checkRequired bool) (errs util.Errors)

Validate validates the values of the tree using the supplied Func.

func Validate2

func Validate2(validations map[string]ValidatorFunc, iop *v1alpha1.IstioOperatorSpec) (errs util.Errors)

func ValuesValidate

func ValuesValidate(validations map[string]ValidatorFunc, node any, path util.Path) (errs util.Errors)

ValuesValidate validates the values of the tree using the supplied Func

Types

type ValidatorFunc

type ValidatorFunc func(path util.Path, i any) util.Errors

ValidatorFunc validates a value.

Jump to

Keyboard shortcuts

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