Documentation ¶
Index ¶
Constants ¶
const ScopedVarName = "self"
ScopedVarName is the variable name assigned to the locally scoped data element of a CEL valid.
Variables ¶
This section is empty.
Functions ¶
func NewValidationActivation ¶
func NewValidationActivation(obj interface{}, structural *schema.Structural) *validationActivation
func UnstructuredToVal ¶
func UnstructuredToVal(unstructured interface{}, schema *structuralschema.Structural) ref.Val
UnstructuredToVal converts a Kubernetes unstructured data element to a CEL Val. The root schema of custom resource schema is expected contain type meta and object meta schemas. If Embedded resources do not contain type meta and object meta schemas, they will be added automatically.
Types ¶
type CompilationResult ¶
CompilationResult represents the cel compilation result for one rule
func Compile ¶
func Compile(s *schema.Structural, isResourceRoot bool) ([]CompilationResult, error)
Compile compiles all the XValidations rules (without recursing into the schema) and returns a slice containing a CompilationResult for each ValidationRule, or an error. Each CompilationResult may contain: / - non-nil Program, nil Error: The program was compiled successfully
- nil Program, non-nil Error: Compilation resulted in an error
- nil Program, nil Error: The provided rule was empty so compilation was not attempted
type Error ¶
Error is an implementation of the 'error' interface, which represents a XValidation error.
type ErrorType ¶
type ErrorType string
ErrorType is a machine readable value providing more detail about why a XValidation is invalid.
const ( // ErrorTypeRequired is used to report withNullable values that are not // provided (e.g. empty strings, null values, or empty arrays). See // Required(). ErrorTypeRequired ErrorType = "RuleRequired" // ErrorTypeInvalid is used to report malformed values ErrorTypeInvalid ErrorType = "RuleInvalid" // ErrorTypeInternal is used to report other errors that are not related // to user input. See InternalError(). ErrorTypeInternal ErrorType = "InternalError" )
type Validator ¶
type Validator struct { Items *Validator Properties map[string]Validator AdditionalProperties *Validator // contains filtered or unexported fields }
Validator parallels the structure of schema.Structural and includes the compiled CEL programs for the x-kubernetes-validations of each schema node.
func NewValidator ¶
func NewValidator(s *schema.Structural) *Validator
NewValidator returns compiles all the CEL programs defined in x-kubernetes-validations extensions of the Structural schema and returns a custom resource validator that contains nested validators for all items, properties and additionalProperties that transitively contain validator rules. Returns nil only if there no validator rules in the Structural schema. May return a validator containing only errors.