ratcheting: disable correlation by index
discussion: https://github.com/kubernetes/kubernetes/pull/121118#discussion_r1358865893 Kubernetes-commit: fb1fc8b4a72758688d1251278579b2b0ac666fc7
This commit is contained in:
parent
b5ac4f9a61
commit
8a3fe0e45c
|
@ -114,19 +114,15 @@ func (r *CorrelatedObject) correlateOldValueForChildAtNewIndex(index int) interf
|
|||
// of value
|
||||
// (would allow you to add/remove items from sets with ratcheting but not change them)
|
||||
return nil
|
||||
case "":
|
||||
fallthrough
|
||||
case "atomic":
|
||||
// Atomic lists are not correlatable by item
|
||||
// Atomic lists are the default are not correlatable by item
|
||||
// Ratcheting is not available on a per-index basis
|
||||
return nil
|
||||
default:
|
||||
// Correlate by-index by default.
|
||||
//
|
||||
// Cannot correlate an out-of-bounds index
|
||||
if len(oldAsList) <= index {
|
||||
return nil
|
||||
}
|
||||
|
||||
return oldAsList[index]
|
||||
// Unrecognized list type. Assume non-correlatable.
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -142,16 +142,14 @@ func TestCorrelation(t *testing.T) {
|
|||
OldValue: "b",
|
||||
},
|
||||
{
|
||||
Name: "Basic Index",
|
||||
Name: "Atomic Array not correlatable",
|
||||
RootObject: mustUnstructured(`[a, b]`),
|
||||
RootOldObject: mustUnstructured(`[a, b]`),
|
||||
Schema: mustSchema(`
|
||||
items:
|
||||
type: string
|
||||
`),
|
||||
KeyPath: []interface{}{1},
|
||||
NewValue: "b",
|
||||
OldValue: "b",
|
||||
KeyPath: []interface{}{1},
|
||||
},
|
||||
{
|
||||
Name: "Added Key Not In Old Object",
|
||||
|
@ -187,7 +185,7 @@ func TestCorrelation(t *testing.T) {
|
|||
KeyPath: []interface{}{2},
|
||||
},
|
||||
{
|
||||
Name: "Changed Index In Old Object",
|
||||
Name: "Changed Index In Old Object not correlatable",
|
||||
RootObject: []interface{}{
|
||||
"a",
|
||||
"b",
|
||||
|
@ -200,9 +198,7 @@ func TestCorrelation(t *testing.T) {
|
|||
items:
|
||||
type: string
|
||||
`),
|
||||
KeyPath: []interface{}{1},
|
||||
NewValue: "b",
|
||||
OldValue: "oldB",
|
||||
KeyPath: []interface{}{1},
|
||||
},
|
||||
{
|
||||
Name: "Changed Index In Nested Old Object",
|
||||
|
|
Loading…
Reference in New Issue