apiextensions-apiserverk8s.io/apiextensions-apiserver/pkg/apiserver/validation Index | Files

package validation

import "k8s.io/apiextensions-apiserver/pkg/apiserver/validation"

Index

Functions

func ConvertJSONSchemaProps

func ConvertJSONSchemaProps(in *apiextensions.JSONSchemaProps, out *spec.Schema) error

ConvertJSONSchemaProps converts the schema from apiextensions.JSONSchemaPropos to go-openapi/spec.Schema.

func ConvertJSONSchemaPropsWithPostProcess

func ConvertJSONSchemaPropsWithPostProcess(in *apiextensions.JSONSchemaProps, out *spec.Schema, postProcess PostProcessFunc) error

ConvertJSONSchemaPropsWithPostProcess converts the schema from apiextensions.JSONSchemaPropos to go-openapi/spec.Schema and run a post process step on each JSONSchemaProps node. postProcess is never called for nil schemas.

func StripUnsupportedFormatsPostProcess

func StripUnsupportedFormatsPostProcess(s *spec.Schema) error

StripUnsupportedFormatsPostProcess sets unsupported formats to empty string.

func ValidateCustomResource

func ValidateCustomResource(fldPath *field.Path, customResource interface{}, validator SchemaCreateValidator) field.ErrorList

ValidateCustomResource validates the Custom Resource against the schema in the CustomResourceDefinition. CustomResource is a JSON data structure.

func ValidateCustomResourceUpdate

func ValidateCustomResourceUpdate(fldPath *field.Path, customResource, old interface{}, validator SchemaValidator) field.ErrorList

ValidateCustomResourceUpdate validates the transition of Custom Resource from `old` to `new` against the schema in the CustomResourceDefinition. Both customResource and old represent a JSON data structures.

If feature `CRDValidationRatcheting` is disabled, this behaves identically to ValidateCustomResource(customResource).

Types

type PostProcessFunc

type PostProcessFunc func(*spec.Schema) error

PostProcessFunc post-processes one node of a spec.Schema.

type RatchetingSchemaValidator

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

RatchetingSchemaValidator wraps kube-openapis SchemaValidator to provide a ValidateUpdate function which allows ratcheting

func NewRatchetingSchemaValidator

func NewRatchetingSchemaValidator(schema *spec.Schema, rootSchema interface{}, root string, formats strfmt.Registry, options ...validate.Option) *RatchetingSchemaValidator

func (*RatchetingSchemaValidator) Validate

func (r *RatchetingSchemaValidator) Validate(new interface{}) *validate.Result

func (*RatchetingSchemaValidator) ValidateUpdate

func (r *RatchetingSchemaValidator) ValidateUpdate(new, old interface{}) *validate.Result

type SchemaCreateValidator

type SchemaCreateValidator interface {
	Validate(value interface{}) *validate.Result
}

type SchemaValidator

type SchemaValidator interface {
	SchemaCreateValidator
	ValidateUpdate(new, old interface{}) *validate.Result
}

func NewSchemaValidator

func NewSchemaValidator(customResourceValidation *apiextensions.JSONSchemaProps) (SchemaValidator, *spec.Schema, error)

NewSchemaValidator creates an openapi schema validator for the given CRD validation.

If feature `CRDValidationRatcheting` is disabled, this returns validator which validates all `Update`s and `Create`s as a `Create` - without considering old value.

If feature `CRDValidationRatcheting` is enabled - the validator returned will support ratcheting unchanged correlatable fields across an update.

Source Files

formats.go ratcheting.go validation.go

Version
v0.28.6
Published
Jan 17, 2024
Platform
js/wasm
Imports
15 packages
Last checked
1 hour ago

Tools for package owners.