Remove superseded history attribution paths
This commit is contained in:
@@ -7,22 +7,10 @@ import "gitea.maximumdirect.net/eric/ConfigKit/internal/document"
|
||||
type Metadata struct {
|
||||
effectivePaths map[string]Path
|
||||
fields map[string]FieldInfo
|
||||
history map[string][]Change
|
||||
inheritance []inheritanceOperation
|
||||
historyBuilder *historyBuilder
|
||||
historyModel *historyModel
|
||||
}
|
||||
|
||||
func (m Metadata) currentHistoryModel() *historyModel {
|
||||
if m.historyModel != nil {
|
||||
return m.historyModel
|
||||
}
|
||||
if m.historyBuilder != nil {
|
||||
return m.historyBuilder.model
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Lookup returns information for an effective path. Unknown and invalid paths
|
||||
// return false.
|
||||
func (m Metadata) Lookup(path Path) (FieldInfo, bool) {
|
||||
@@ -155,80 +143,13 @@ func (m Metadata) hasHistoricalPath(path Path) bool {
|
||||
return m.historyEvidence().hasObservedShape(path)
|
||||
}
|
||||
|
||||
func finalizeMetadataPaths(m *Metadata, final *document.Node, applications []historyApplication, earlier ...*document.Node) {
|
||||
finalizeMetadataPathsWithResolution(m, final, applications, nil, earlier...)
|
||||
}
|
||||
|
||||
func finalizeMetadataPathsWithResolution(m *Metadata, final *document.Node, applications []historyApplication, snapshots []resolutionSnapshot, earlier ...*document.Node) {
|
||||
func freezeMetadataHistory(m *Metadata, final *document.Node) {
|
||||
finalizeEffectiveMetadataPaths(m, final)
|
||||
builder := m.historyBuilder
|
||||
if builder != nil && builder.prefixReady {
|
||||
if len(snapshots) != 0 && builder.model.resolutionPayload == nil {
|
||||
if len(earlier) != 0 {
|
||||
builder.setScratch(earlier[len(earlier)-1])
|
||||
}
|
||||
builder.observeResolutionEvidence(snapshots)
|
||||
}
|
||||
if builder.model.final != final {
|
||||
builder.model.final = final
|
||||
}
|
||||
m.historyModel = builder.freeze()
|
||||
m.historyBuilder = nil
|
||||
return
|
||||
}
|
||||
if builder == nil {
|
||||
builder = newHistoryBuilder()
|
||||
}
|
||||
if len(earlier) != 0 {
|
||||
builder.model.baseline = earlier[0]
|
||||
if builder == nil || !builder.prefixReady {
|
||||
panic("configkit: metadata history prefix is not ready")
|
||||
}
|
||||
builder.model.final = final
|
||||
for index, tree := range earlier {
|
||||
phase := historyPhaseSources
|
||||
switch index {
|
||||
case 0:
|
||||
phase = historyPhaseBaseline
|
||||
case 2:
|
||||
phase = historyPhasePreCLI
|
||||
case 3:
|
||||
phase = historyPhasePostCLI
|
||||
}
|
||||
builder.observeDocument(tree, phase)
|
||||
}
|
||||
if final != nil {
|
||||
builder.observeDocument(final, historyPhasePostCLI)
|
||||
}
|
||||
for _, application := range applications {
|
||||
phase := historyPhaseSources
|
||||
if application.layer == LayerCLI {
|
||||
phase = historyPhaseCLI
|
||||
}
|
||||
payload := builder.nextPayload(phase)
|
||||
walkHistoryApplication(application, func(_, effective Path, node *document.Node) {
|
||||
builder.addInventoryObservation(effective, effective, payload, phase, node.Sensitive)
|
||||
})
|
||||
}
|
||||
for _, operation := range m.inheritance {
|
||||
payload := builder.nextPayload(historyPhaseInheritance)
|
||||
if operation.control != nil {
|
||||
builder.addInventoryObservation(operation.control.path, operation.control.path, payload, historyPhaseInheritance, false)
|
||||
continue
|
||||
}
|
||||
if operation.transfer == nil {
|
||||
continue
|
||||
}
|
||||
for _, root := range []*document.Node{operation.parent, operation.effective} {
|
||||
walkDocument(root, operation.transfer.to, func(path Path, node *document.Node) {
|
||||
builder.addInventoryObservation(path, path, payload, historyPhaseInheritance, node.Sensitive)
|
||||
})
|
||||
}
|
||||
}
|
||||
if len(snapshots) != 0 {
|
||||
if len(earlier) != 0 {
|
||||
builder.setScratch(earlier[len(earlier)-1])
|
||||
}
|
||||
builder.observeResolutionEvidence(snapshots)
|
||||
}
|
||||
m.historyModel = builder.freeze()
|
||||
m.historyBuilder = nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user