Documentation ¶
Index ¶
- func ConvertJSONSchemaProps(in *apiextensions.JSONSchemaProps, out *spec.Schema) error
- func ConvertJSONSchemaPropsWithPostProcess(in *apiextensions.JSONSchemaProps, out *spec.Schema, ...) error
- func StripUnsupportedFormatsPostProcess(s *spec.Schema) error
- func ValidateCustomResource(fldPath *field.Path, customResource interface{}, ...) field.ErrorList
- func ValidateCustomResourceUpdate(fldPath *field.Path, customResource, old interface{}, ...) field.ErrorList
- type PostProcessFunc
- type RatchetingSchemaValidator
- type SchemaCreateValidator
- type SchemaValidator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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 ¶ added in v0.17.0
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 ¶ added in v0.28.0
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 ¶ added in v0.28.0
type RatchetingSchemaValidator struct {
// contains filtered or unexported fields
}
RatchetingSchemaValidator wraps kube-openapis SchemaValidator to provide a ValidateUpdate function which allows ratcheting
func NewRatchetingSchemaValidator ¶ added in v0.28.0
func (*RatchetingSchemaValidator) Validate ¶ added in v0.28.0
func (r *RatchetingSchemaValidator) Validate(new interface{}) *validate.Result
func (*RatchetingSchemaValidator) ValidateUpdate ¶ added in v0.28.0
func (r *RatchetingSchemaValidator) ValidateUpdate(new, old interface{}) *validate.Result
type SchemaCreateValidator ¶ added in v0.28.0
type SchemaValidator ¶ added in v0.28.0
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.