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
|
// of value
|
||||||
// (would allow you to add/remove items from sets with ratcheting but not change them)
|
// (would allow you to add/remove items from sets with ratcheting but not change them)
|
||||||
return nil
|
return nil
|
||||||
|
case "":
|
||||||
|
fallthrough
|
||||||
case "atomic":
|
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
|
// Ratcheting is not available on a per-index basis
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
// Correlate by-index by default.
|
// Unrecognized list type. Assume non-correlatable.
|
||||||
//
|
return nil
|
||||||
// Cannot correlate an out-of-bounds index
|
|
||||||
if len(oldAsList) <= index {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return oldAsList[index]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,16 +142,14 @@ func TestCorrelation(t *testing.T) {
|
||||||
OldValue: "b",
|
OldValue: "b",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "Basic Index",
|
Name: "Atomic Array not correlatable",
|
||||||
RootObject: mustUnstructured(`[a, b]`),
|
RootObject: mustUnstructured(`[a, b]`),
|
||||||
RootOldObject: mustUnstructured(`[a, b]`),
|
RootOldObject: mustUnstructured(`[a, b]`),
|
||||||
Schema: mustSchema(`
|
Schema: mustSchema(`
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
`),
|
`),
|
||||||
KeyPath: []interface{}{1},
|
KeyPath: []interface{}{1},
|
||||||
NewValue: "b",
|
|
||||||
OldValue: "b",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "Added Key Not In Old Object",
|
Name: "Added Key Not In Old Object",
|
||||||
|
@ -187,7 +185,7 @@ func TestCorrelation(t *testing.T) {
|
||||||
KeyPath: []interface{}{2},
|
KeyPath: []interface{}{2},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "Changed Index In Old Object",
|
Name: "Changed Index In Old Object not correlatable",
|
||||||
RootObject: []interface{}{
|
RootObject: []interface{}{
|
||||||
"a",
|
"a",
|
||||||
"b",
|
"b",
|
||||||
|
@ -200,9 +198,7 @@ func TestCorrelation(t *testing.T) {
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
`),
|
`),
|
||||||
KeyPath: []interface{}{1},
|
KeyPath: []interface{}{1},
|
||||||
NewValue: "b",
|
|
||||||
OldValue: "oldB",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "Changed Index In Nested Old Object",
|
Name: "Changed Index In Nested Old Object",
|
||||||
|
|
Loading…
Reference in New Issue