package validation
import "k8s.io/apiextensions-apiserver/pkg/apiserver/validation"
Index ¶
- func ConvertJSONSchemaProps(in *apiextensions.JSONSchemaProps, out *spec.Schema) error
- func ConvertJSONSchemaPropsWithPostProcess(in *apiextensions.JSONSchemaProps, out *spec.Schema, postProcess PostProcessFunc) error
- func StripUnsupportedFormatsPostProcess(s *spec.Schema) error
- func ValidateCustomResource(fldPath *field.Path, customResource interface{}, validator SchemaCreateValidator) field.ErrorList
- func ValidateCustomResourceUpdate(fldPath *field.Path, customResource, old interface{}, validator SchemaValidator) field.ErrorList
- type PostProcessFunc
- type RatchetingSchemaValidator
- func NewRatchetingSchemaValidator(schema *spec.Schema, rootSchema interface{}, root string, formats strfmt.Registry, options ...validate.Option) *RatchetingSchemaValidator
- func (r *RatchetingSchemaValidator) Validate(new interface{}) *validate.Result
- func (r *RatchetingSchemaValidator) ValidateUpdate(new, old interface{}) *validate.Result
- type SchemaCreateValidator
- type SchemaValidator
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 ¶
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 ¶
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 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.29.0-alpha.1
- Published
- Sep 25, 2023
- Platform
- js/wasm
- Imports
- 15 packages
- Last checked
- 53 seconds ago –
Tools for package owners.