Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions typed/reconcile_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,13 @@ func buildGranularFieldSet(path fieldpath.Path, value *TypedValue) (*fieldpath.S
if err != nil {
return nil, errorf("toFieldSet: %v", err)
}
result := fieldpath.NewSet(path)
resultAtPath := descendToPath(result, path)
if valueFieldSetAtPath, ok := fieldSetAtPath(valueFieldSet, path); ok {
result := fieldpath.NewSet(path)
resultAtPath := descendToPath(result, path)
*resultAtPath = *valueFieldSetAtPath
return result, nil
}
return result, nil
return nil, nil
}

func fieldSetAtPath(node *fieldpath.Set, path fieldpath.Path) (*fieldpath.Set, bool) {
Expand Down
23 changes: 23 additions & 0 deletions typed/reconcile_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,29 @@ var reconcileCases = []reconcileTestCase{{
_P("unchanged", "numeric"),
),
fixedFields: nil, // indicates no change
}, {
name: "no-change-empty-granular",
rootTypeName: "v1",
oldSchema: granularSchema("v1"),
newSchema: granularSchema("v1"),
liveObject: typed.YAMLObject(`
struct: {}
list: []
objectList:
- keyA: a1
keyB: b1
stringMap: {}
unchanged: {}
`),
oldFields: _NS(
_P("struct"),
_P("list"),
_P("objectList"),
_P("objectList", _KBF("keyA", "a1", "keyB", "b1")),
_P("objectList", _KBF("keyA", "a1", "keyB", "b1"), "value"),
_P("unchanged"),
),
fixedFields: nil, // indicates no change
}}

func TestReconcileFieldSetWithSchema(t *testing.T) {
Expand Down