istio: Index | Files

package validate

import ""


Package Files

common.go validate.go validate_values.go


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(
        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(`/`)),
        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}`)
var (
    // DefaultValidations maps a data path to a validation function.
    DefaultValidations = map[string]ValidatorFunc{
        "Values": func(path util.Path, i interface{}) util.Errors {
            return CheckValues(i)
        "MeshConfig":                         validateMeshConfig,
        "Hub":                                validateHub,
        "Tag":                                validateTag,
        "Revision":                           validateRevision,
        "Components.IngressGateways[*].Name": validateGatewayName,
        "Components.EgressGateways[*].Name":  validateGatewayName,
var (
    // DefaultValuesValidations maps a data path to a validation function.
    DefaultValuesValidations = map[string]ValidatorFunc{
        "global.proxy.includeIPRanges":     validateIPRangesOrStar,
        "global.proxy.excludeIPRanges":     validateIPRangesOrStar,
        "global.proxy.includeInboundPorts": validateStringList(validatePortNumberString),
        "global.proxy.excludeInboundPorts": validateStringList(validatePortNumberString),
        "meshConfig":                       validateMeshConfig,

func CheckIstioOperator Uses

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

CheckIstioOperator validates the operator CR.

func CheckIstioOperatorSpec Uses

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 Uses

func CheckValues(root interface{}) util.Errors

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

func UnmarshalIOP Uses

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

UnmarshalIOP unmarshals a string containing IstioOperator as YAML.

func ValidIOP Uses

func ValidIOP(iop *v1alpha1.IstioOperator) error

ValidIOP validates the given IstioOperator object.

func Validate Uses

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

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

func ValuesValidate Uses

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

ValuesValidate validates the values of the tree using the supplied Func

type ValidatorFunc Uses

type ValidatorFunc func(path util.Path, i interface{}) util.Errors

ValidatorFunc validates a value.

Package validate imports 17 packages (graph) and is imported by 5 packages. Updated 2020-11-20. Refresh now. Tools for package owners.