Skip to content

Commit b3cf1e8

Browse files
authored
Merge pull request #176 from jpbetz/fix-noop-granular-case
Fix noop granular case for atomic<->granular schema changes
2 parents 0ca72c0 + 8443f34 commit b3cf1e8

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

typed/reconcile_schema.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,13 @@ func buildGranularFieldSet(path fieldpath.Path, value *TypedValue) (*fieldpath.S
258258
if err != nil {
259259
return nil, errorf("toFieldSet: %v", err)
260260
}
261-
result := fieldpath.NewSet(path)
262-
resultAtPath := descendToPath(result, path)
263261
if valueFieldSetAtPath, ok := fieldSetAtPath(valueFieldSet, path); ok {
262+
result := fieldpath.NewSet(path)
263+
resultAtPath := descendToPath(result, path)
264264
*resultAtPath = *valueFieldSetAtPath
265+
return result, nil
265266
}
266-
return result, nil
267+
return nil, nil
267268
}
268269

269270
func fieldSetAtPath(node *fieldpath.Set, path fieldpath.Path) (*fieldpath.Set, bool) {

typed/reconcile_schema_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,29 @@ var reconcileCases = []reconcileTestCase{{
267267
_P("unchanged", "numeric"),
268268
),
269269
fixedFields: nil, // indicates no change
270+
}, {
271+
name: "no-change-empty-granular",
272+
rootTypeName: "v1",
273+
oldSchema: granularSchema("v1"),
274+
newSchema: granularSchema("v1"),
275+
liveObject: typed.YAMLObject(`
276+
struct: {}
277+
list: []
278+
objectList:
279+
- keyA: a1
280+
keyB: b1
281+
stringMap: {}
282+
unchanged: {}
283+
`),
284+
oldFields: _NS(
285+
_P("struct"),
286+
_P("list"),
287+
_P("objectList"),
288+
_P("objectList", _KBF("keyA", "a1", "keyB", "b1")),
289+
_P("objectList", _KBF("keyA", "a1", "keyB", "b1"), "value"),
290+
_P("unchanged"),
291+
),
292+
fixedFields: nil, // indicates no change
270293
}}
271294

272295
func TestReconcileFieldSetWithSchema(t *testing.T) {

0 commit comments

Comments
 (0)