validation

package
v0.0.0-...-a2cdc83 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const FieldImmutableErrorMsg string = `field is immutable`
View Source
const IsNegativeErrorMsg string = `must be greater than or equal to 0`

Variables

View Source
var BannedOwners = map[string]struct{}{
	"event": {},
}

BannedOwners is a black list of object that are not allowed to be owners.

View Source
var ValidateNamespaceName = NameIsDNSLabel

ValidateNamespaceName can be used to check whether the given namespace name is valid. Prefix indicates this name will be used as part of generation, in which case trailing dashes are allowed.

View Source
var ValidateNodeName = NameIsDNSSubdomain
View Source
var ValidatePodName = NameIsDNSSubdomain
View Source
var ValidateServiceAccountName = NameIsDNSSubdomain

ValidateServiceAccountName can be used to check whether the given service account name is valid. Prefix indicates this name will be used as part of generation, in which case trailing dashes are allowed.

Functions

func AccumulateUniqueHostPorts

func AccumulateUniqueHostPorts(containers []v1.Container, accumulator *sets.String, fldPath *field.Path) field.ErrorList

AccumulateUniqueHostPorts extracts each HostPort of each Container, accumulating the results and returning an error if any ports conflict.

func GetVolumeMountMap

func GetVolumeMountMap(mounts []v1.VolumeMount) map[string]string

func IsMatchedVolume

func IsMatchedVolume(name string, volumes map[string]v1.VolumeSource) bool

func NameIsDNS1035Label

func NameIsDNS1035Label(name string, prefix bool) []string

NameIsDNS1035Label is a ValidateNameFunc for names that must be a DNS 952 label.

func NameIsDNSLabel

func NameIsDNSLabel(name string, prefix bool) []string

NameIsDNSLabel is a ValidateNameFunc for names that must be a DNS 1123 label.

func NameIsDNSSubdomain

func NameIsDNSSubdomain(name string, prefix bool) []string

NameIsDNSSubdomain is a ValidateNameFunc for names that must be a DNS subdomain.

func ValidateAnnotations

func ValidateAnnotations(annotations map[string]string, fldPath *field.Path) field.ErrorList

ValidateAnnotations validates that a set of annotations are correctly defined.

func ValidateContainerUpdates

func ValidateContainerUpdates(newContainers, oldContainers []v1.Container, fldPath *field.Path) (allErrs field.ErrorList, stop bool)

func ValidateDNS1123Label

func ValidateDNS1123Label(value string, fldPath *field.Path) field.ErrorList

func ValidateDNS1123Subdomain

func ValidateDNS1123Subdomain(value string, fldPath *field.Path) field.ErrorList

ValidateDNS1123Subdomain validates that a name is a proper DNS subdomain.

func ValidateEnv

func ValidateEnv(vars []v1.EnvVar, fldPath *field.Path) field.ErrorList

ValidateEnv validates env vars

func ValidateImmutableField

func ValidateImmutableField(newVal, oldVal interface{}, fldPath *field.Path) field.ErrorList

ValidateImmutableField validates the new value and the old value are deeply equal.

func ValidateLabelName

func ValidateLabelName(labelName string, fldPath *field.Path) field.ErrorList

ValidateLabelName validates that the label name is correctly defined.

func ValidateLabelSelector

func ValidateLabelSelector(ps *v1.LabelSelector, fldPath *field.Path) field.ErrorList

func ValidateLabelSelectorRequirement

func ValidateLabelSelectorRequirement(sr v1.LabelSelectorRequirement, fldPath *field.Path) field.ErrorList

func ValidateLabels

func ValidateLabels(labels map[string]string, fldPath *field.Path) field.ErrorList

ValidateLabels validates that a set of labels are correctly defined.

func ValidateNonnegativeField

func ValidateNonnegativeField(value int64, fldPath *field.Path) field.ErrorList

ValidateNonnegativeField Validates that given value is not negative.

func ValidateObjectMeta

func ValidateObjectMeta(objMeta *metav1.ObjectMeta, requiresNamespace bool, nameFn ValidateNameFunc, fldPath *field.Path) field.ErrorList

func ValidateObjectMetaAccessor

func ValidateObjectMetaAccessor(meta metav1.Object, requiresNamespace bool, nameFn ValidateNameFunc, fldPath *field.Path) field.ErrorList

func ValidateObjectMetaAccessorUpdate

func ValidateObjectMetaAccessorUpdate(newMeta, oldMeta metav1.Object, fldPath *field.Path) field.ErrorList

ValidateObjectMetaAccessorUpdate validates an object's metadata when updated.

func ValidateObjectMetaUpdate

func ValidateObjectMetaUpdate(newMeta, oldMeta *metav1.ObjectMeta, fldPath *field.Path) field.ErrorList

func ValidateOwnerReferences

func ValidateOwnerReferences(ownerReferences []metav1.OwnerReference, fldPath *field.Path) field.ErrorList

func ValidatePod

func ValidatePod(pod *v1.Pod) field.ErrorList

func ValidatePodSecurityContext

func ValidatePodSecurityContext(securityContext *v1.PodSecurityContext, fldPath *field.Path) field.ErrorList

ValidatePodSecurityContext test that the specified PodSecurityContext has valid data.

func ValidatePodSpec

func ValidatePodSpec(spec *v1.PodSpec, fldPath *field.Path) field.ErrorList

ValidatePodSpec tests that the specified PodSpec has valid data. This includes checking formatting and uniqueness. It also canonicalizes the structure by setting default values and implementing any backwards-compatibility tricks.

func ValidatePodSpecificAnnotationUpdates

func ValidatePodSpecificAnnotationUpdates(newPod, oldPod *v1.Pod, fldPath *field.Path) field.ErrorList

func ValidatePodSpecificAnnotations

func ValidatePodSpecificAnnotations(annotations map[string]string, spec *v1.PodSpec, fldPath *field.Path) field.ErrorList

func ValidatePodTemplateSpecForStatefulSet

func ValidatePodTemplateSpecForStatefulSet(template *v1.PodTemplateSpec, fldPath *field.Path) field.ErrorList

func ValidatePodUpdate

func ValidatePodUpdate(newPod, oldPod *v1.Pod) field.ErrorList

func ValidateResourceRequirements

func ValidateResourceRequirements(requirements *v1.ResourceRequirements, fldPath *field.Path) field.ErrorList

func ValidateSecurityContext

func ValidateSecurityContext(sc *v1.SecurityContext, fldPath *field.Path) field.ErrorList

ValidateSecurityContext ensure the security context contains valid settings

func ValidateStatefulSet

func ValidateStatefulSet(statefulSet *v1.StatefulSet) field.ErrorList

ValidateStatefulSet validates a StatefulSet.

func ValidateStatefulSetName

func ValidateStatefulSetName(name string, prefix bool) []string

func ValidateStatefulSetSpec

func ValidateStatefulSetSpec(spec *v1.StatefulSetSpec, fldPath *field.Path) field.ErrorList

ValidateStatefulSetSpec tests if required fields in the StatefulSet spec are set.

func ValidateStatefulSetStatusUpdate

func ValidateStatefulSetStatusUpdate(statefulSet, oldStatefulSet *v1.StatefulSet) field.ErrorList

ValidateStatefulSetStatusUpdate tests if required fields in the StatefulSet are set.

func ValidateStatefulSetUpdate

func ValidateStatefulSetUpdate(statefulSet, oldStatefulSet *v1.StatefulSet) field.ErrorList

ValidateStatefulSetUpdate tests if required fields in the StatefulSet are set.

func ValidateVolumeMounts

func ValidateVolumeMounts(mounts []v1.VolumeMount, volumes map[string]v1.VolumeSource, fldPath *field.Path) field.ErrorList

func ValidateVolumes

func ValidateVolumes(volumes []v1.Volume, fldPath *field.Path) (map[string]v1.VolumeSource, field.ErrorList)

Types

type ValidateNameFunc

type ValidateNameFunc func(name string, prefix bool) []string

ValidateNameFunc validates that the provided name is valid for a given resource type. Not all resources have the same validation rules for names. Prefix is true if the name will have a value appended to it. If the name is not valid, this returns a list of descriptions of individual characteristics of the value that were not valid. Otherwise, this returns an empty list or nil.

Jump to

Keyboard shortcuts

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