mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Merge pull request #53762 from smarterclayton/reflect_diff
Automatic merge from submit-queue (batch tested with PRs 53749, 53642, 53813, 53771, 53762). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Don't exit early in diff.ObjectReflectDiff on slices
This commit is contained in:
commit
fe3b68ecc6
@ -142,10 +142,6 @@ func objectReflectDiff(path *field.Path, a, b reflect.Value) []diff {
|
|||||||
}
|
}
|
||||||
if sub := objectReflectDiff(path.Child(a.Type().Field(i).Name), a.Field(i), b.Field(i)); len(sub) > 0 {
|
if sub := objectReflectDiff(path.Child(a.Type().Field(i).Name), a.Field(i), b.Field(i)); len(sub) > 0 {
|
||||||
changes = append(changes, sub...)
|
changes = append(changes, sub...)
|
||||||
} else {
|
|
||||||
if !reflect.DeepEqual(a.Field(i).Interface(), b.Field(i).Interface()) {
|
|
||||||
changes = append(changes, diff{path: path, a: a.Field(i).Interface(), b: b.Field(i).Interface()})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changes
|
return changes
|
||||||
@ -178,21 +174,18 @@ func objectReflectDiff(path *field.Path, a, b reflect.Value) []diff {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
var diffs []diff
|
||||||
for i := 0; i < l; i++ {
|
for i := 0; i < l; i++ {
|
||||||
if !reflect.DeepEqual(a.Index(i), b.Index(i)) {
|
if !reflect.DeepEqual(a.Index(i), b.Index(i)) {
|
||||||
return objectReflectDiff(path.Index(i), a.Index(i), b.Index(i))
|
diffs = append(diffs, objectReflectDiff(path.Index(i), a.Index(i), b.Index(i))...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var diffs []diff
|
|
||||||
for i := l; i < lA; i++ {
|
for i := l; i < lA; i++ {
|
||||||
diffs = append(diffs, diff{path: path.Index(i), a: a.Index(i), b: nil})
|
diffs = append(diffs, diff{path: path.Index(i), a: a.Index(i), b: nil})
|
||||||
}
|
}
|
||||||
for i := l; i < lB; i++ {
|
for i := l; i < lB; i++ {
|
||||||
diffs = append(diffs, diff{path: path.Index(i), a: nil, b: b.Index(i)})
|
diffs = append(diffs, diff{path: path.Index(i), a: nil, b: b.Index(i)})
|
||||||
}
|
}
|
||||||
if len(diffs) == 0 {
|
|
||||||
diffs = append(diffs, diff{path: path, a: a, b: b})
|
|
||||||
}
|
|
||||||
return diffs
|
return diffs
|
||||||
case reflect.Map:
|
case reflect.Map:
|
||||||
if reflect.DeepEqual(a.Interface(), b.Interface()) {
|
if reflect.DeepEqual(a.Interface(), b.Interface()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user