type schemaArgs … type RatchetingSchemaValidator … func NewRatchetingSchemaValidator(schema *spec.Schema, rootSchema interface{ … } func (r *RatchetingSchemaValidator) Validate(new interface{ … } func (r *RatchetingSchemaValidator) ValidateUpdate(new, old interface{ … } type ratchetingValueValidator … func newRatchetingValueValidator(correlation *common.CorrelatedObject, args schemaArgs) *ratchetingValueValidator { … } // getValidateOption provides a kube-openapi validate.Option for SchemaValidator // that injects a ratchetingValueValidator to be used for all subkeys and subindices func (r *ratchetingValueValidator) getValidateOption() validate.Option { … } // Validate validates the update from r.oldValue to r.value // // During evaluation, a temporary tree of ratchetingValueValidator is built for all // traversed field paths. It is necessary to build the tree to take advantage of // DeepEqual checks performed by lower levels of the object during validation without // greatly modifying `kube-openapi`'s implementation. // // The tree, and all cache storage/scratch space for the validation of a single // call to `Validate` is thrown away at the end of the top-level call // to `Validate`. // // `Validate` will create a node in the tree to for each of the explored children. // The node's main purpose is to store a lazily computed DeepEqual check between // the oldValue and the currently passed value. If the check is performed, it // will be stored in the node to be re-used by a parent node during a DeepEqual // comparison, if necessary. // // This call has a side-effect of populating it's `children` variable with // the explored nodes of the object tree. func (r *ratchetingValueValidator) Validate(new interface{ … } // SubPropertyValidator overrides the standard validator constructor for sub-properties by // returning our special ratcheting variant. // // If we can correlate an old value, we return a ratcheting validator to // use for the child. // // If the old value cannot be correlated, then default validation is used. func (r *ratchetingValueValidator) SubPropertyValidator(field string, schema *spec.Schema, rootSchema interface{ … } // SubIndexValidator overrides the standard validator constructor for sub-indicies by // returning our special ratcheting variant. // // If we can correlate an old value, we return a ratcheting validator to // use for the child. // // If the old value cannot be correlated, then default validation is used. func (r *ratchetingValueValidator) SubIndexValidator(index int, schema *spec.Schema, rootSchema interface{ … } var _ … func (r ratchetingValueValidator) SetPath(path string) { … } func (r ratchetingValueValidator) Applies(source interface{ … } func isTypeMetaField(path string) bool { … }