cleanup: add header and fix spelling

This commit is contained in:
Alexander Zielenski 2023-10-11 13:51:49 -07:00
parent 27cb869e55
commit c08a9321ee
2 changed files with 21 additions and 21 deletions

View File

@ -190,11 +190,11 @@ func (r *ratchetingValueValidator) SubIndexValidator(index int, schema *spec.Sch
var _ validate.ValueValidator = (&ratchetingValueValidator{}) var _ validate.ValueValidator = (&ratchetingValueValidator{})
func (f ratchetingValueValidator) SetPath(path string) { func (r ratchetingValueValidator) SetPath(path string) {
// Do nothing // Do nothing
// Unused by kube-openapi // Unused by kube-openapi
} }
func (f ratchetingValueValidator) Applies(source interface{}, valueKind reflect.Kind) bool { func (r ratchetingValueValidator) Applies(source interface{}, valueKind reflect.Kind) bool {
return true return true
} }

View File

@ -200,16 +200,16 @@ func (r *CorrelatedObject) CachedDeepEqual() (res bool) {
// Returns nil if the given name is does not exist in the new object, or its // Returns nil if the given name is does not exist in the new object, or its
// value is not correlatable to an old value. // value is not correlatable to an old value.
// If receiver is nil or if the new value is not an object/map, returns nil. // If receiver is nil or if the new value is not an object/map, returns nil.
func (l *CorrelatedObject) Key(field string) *CorrelatedObject { func (r *CorrelatedObject) Key(field string) *CorrelatedObject {
if l == nil || l.Schema == nil { if r == nil || r.Schema == nil {
return nil return nil
} else if existing, exists := l.children[field]; exists { } else if existing, exists := r.children[field]; exists {
return existing return existing
} }
// Find correlated old value // Find correlated old value
oldAsMap, okOld := l.OldValue.(map[string]interface{}) oldAsMap, okOld := r.OldValue.(map[string]interface{})
newAsMap, okNew := l.Value.(map[string]interface{}) newAsMap, okNew := r.Value.(map[string]interface{})
if !okOld || !okNew { if !okOld || !okNew {
return nil return nil
} }
@ -221,20 +221,20 @@ func (l *CorrelatedObject) Key(field string) *CorrelatedObject {
} }
var propertySchema Schema var propertySchema Schema
if prop, exists := l.Schema.Properties()[field]; exists { if prop, exists := r.Schema.Properties()[field]; exists {
propertySchema = prop propertySchema = prop
} else if addP := l.Schema.AdditionalProperties(); addP != nil && addP.Schema() != nil { } else if addP := r.Schema.AdditionalProperties(); addP != nil && addP.Schema() != nil {
propertySchema = addP.Schema() propertySchema = addP.Schema()
} else { } else {
return nil return nil
} }
if l.children == nil { if r.children == nil {
l.children = make(map[interface{}]*CorrelatedObject, len(newAsMap)) r.children = make(map[interface{}]*CorrelatedObject, len(newAsMap))
} }
res := NewCorrelatedObject(newValueForField, oldValueForField, propertySchema) res := NewCorrelatedObject(newValueForField, oldValueForField, propertySchema)
l.children[field] = res r.children[field] = res
return res return res
} }
@ -242,34 +242,34 @@ func (l *CorrelatedObject) Key(field string) *CorrelatedObject {
// Returns nil if the given index is out of bounds, or its value is not // Returns nil if the given index is out of bounds, or its value is not
// correlatable to an old value. // correlatable to an old value.
// If receiver is nil or if the new value is not an array, returns nil. // If receiver is nil or if the new value is not an array, returns nil.
func (l *CorrelatedObject) Index(i int) *CorrelatedObject { func (r *CorrelatedObject) Index(i int) *CorrelatedObject {
if l == nil || l.Schema == nil { if r == nil || r.Schema == nil {
return nil return nil
} else if existing, exists := l.children[i]; exists { } else if existing, exists := r.children[i]; exists {
return existing return existing
} }
asList, ok := l.Value.([]interface{}) asList, ok := r.Value.([]interface{})
if !ok || len(asList) <= i { if !ok || len(asList) <= i {
return nil return nil
} }
oldValueForIndex := l.correlateOldValueForChildAtNewIndex(i) oldValueForIndex := r.correlateOldValueForChildAtNewIndex(i)
if oldValueForIndex == nil { if oldValueForIndex == nil {
return nil return nil
} }
var itemSchema Schema var itemSchema Schema
if i := l.Schema.Items(); i != nil { if i := r.Schema.Items(); i != nil {
itemSchema = i itemSchema = i
} else { } else {
return nil return nil
} }
if l.children == nil { if r.children == nil {
l.children = make(map[interface{}]*CorrelatedObject, len(asList)) r.children = make(map[interface{}]*CorrelatedObject, len(asList))
} }
res := NewCorrelatedObject(asList[i], oldValueForIndex, itemSchema) res := NewCorrelatedObject(asList[i], oldValueForIndex, itemSchema)
l.children[i] = res r.children[i] = res
return res return res
} }