Preserve sibling inheritance in configuration history and explanations
This commit is contained in:
@@ -13,6 +13,7 @@ type Metadata struct {
|
||||
historicalPaths map[string][]Path
|
||||
fields map[string]FieldInfo
|
||||
history map[string][]Change
|
||||
inheritance []inheritanceOperation
|
||||
}
|
||||
|
||||
// Lookup returns information for an effective path. Unknown and invalid paths
|
||||
@@ -25,7 +26,9 @@ func (m Metadata) Lookup(path Path) (FieldInfo, bool) {
|
||||
if !ok {
|
||||
return FieldInfo{}, false
|
||||
}
|
||||
return cloneFieldInfo(info), true
|
||||
detached := cloneFieldInfo(info)
|
||||
detached.Origin.Inheritance = projectInheritanceSteps(detached.Origin)
|
||||
return detached, true
|
||||
}
|
||||
|
||||
// IsExplicit reports whether a surviving input contribution explicitly defined
|
||||
@@ -43,15 +46,8 @@ func (m Metadata) History(path Path) []Change {
|
||||
if !m.hasHistoricalPath(path) {
|
||||
return nil
|
||||
}
|
||||
history, ok := m.history[path.String()]
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
cloned := make([]Change, len(history))
|
||||
for i, change := range history {
|
||||
cloned[i] = cloneChange(change)
|
||||
}
|
||||
return cloned
|
||||
history := m.history[path.String()]
|
||||
return historyWithInheritance(path, history, m.inheritance)
|
||||
}
|
||||
|
||||
// HistoricalPaths returns the paths observed during loading, including effective
|
||||
@@ -136,6 +132,16 @@ func finalizeMetadataPaths(m *Metadata, final *document.Node, applications []his
|
||||
}
|
||||
walkDocument(application.value, prefix, add)
|
||||
}
|
||||
for _, operation := range m.inheritance {
|
||||
if operation.control != nil {
|
||||
add(operation.control.path, nil)
|
||||
continue
|
||||
}
|
||||
if operation.transfer != nil {
|
||||
walkDocument(operation.parent, operation.transfer.to, add)
|
||||
walkDocument(operation.effective, operation.transfer.to, add)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// effectivePathIndex records document-derived paths with their contextual segment
|
||||
|
||||
Reference in New Issue
Block a user