Skip to content

Commit 2f57dbd

Browse files
committed
crdupgradesafety: fix to ignore diffs in child items
Signed-off-by: Joe Lanford <[email protected]>
1 parent 48782d9 commit 2f57dbd

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

internal/operator-controller/rukpak/preflights/crdupgradesafety/change_validator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ func CalculateFlatSchemaDiff(o, n FlatSchema) (map[string]FieldDiff, error) {
154154
// we should still detect changes in the children fields.
155155
oldCopy := schema.DeepCopy()
156156
newCopy := newSchema.DeepCopy()
157-
oldCopy.Properties = nil
158-
newCopy.Properties = nil
157+
oldCopy.Properties, oldCopy.Items = nil, nil
158+
newCopy.Properties, newCopy.Items = nil, nil
159159
if !reflect.DeepEqual(oldCopy, newCopy) {
160160
diffMap[field] = FieldDiff{
161161
Old: oldCopy,

internal/operator-controller/rukpak/preflights/crdupgradesafety/change_validator_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,20 @@ func TestCalculateFlatSchemaDiff(t *testing.T) {
6868
},
6969
expectedDiff: map[string]crdupgradesafety.FieldDiff{},
7070
},
71+
{
72+
name: "diff in child items only, no diff returned, no error",
73+
old: crdupgradesafety.FlatSchema{
74+
"foo": &apiextensionsv1.JSONSchemaProps{
75+
Items: &apiextensionsv1.JSONSchemaPropsOrArray{Schema: &apiextensionsv1.JSONSchemaProps{ID: "bar"}},
76+
},
77+
},
78+
new: crdupgradesafety.FlatSchema{
79+
"foo": &apiextensionsv1.JSONSchemaProps{
80+
Items: &apiextensionsv1.JSONSchemaPropsOrArray{Schema: &apiextensionsv1.JSONSchemaProps{ID: "baz"}},
81+
},
82+
},
83+
expectedDiff: map[string]crdupgradesafety.FieldDiff{},
84+
},
7185
{
7286
name: "field exists in old but not new, no diff returned, error",
7387
old: crdupgradesafety.FlatSchema{

0 commit comments

Comments
 (0)