Publish inspection through one frozen history model
This commit is contained in:
@@ -59,7 +59,6 @@ type historyModel struct {
|
||||
attributions []historyAttribution
|
||||
baseline *document.Node
|
||||
final *document.Node
|
||||
inventoryRoots []*document.Node
|
||||
sourcePayloads []historySourcePayload
|
||||
inheritancePayloads []historyInheritancePayload
|
||||
cliPayloads []historySourcePayload
|
||||
@@ -149,20 +148,12 @@ func (builder *historyBuilder) observeDocumentAt(root *document.Node, prefix Pat
|
||||
if root == nil {
|
||||
return
|
||||
}
|
||||
builder.registerDocumentRoot(root)
|
||||
payload := builder.nextPayload(phase)
|
||||
walkDocument(root, prefix, func(path Path, node *document.Node) {
|
||||
builder.addInventoryObservation(path, path, payload, phase, node.Sensitive)
|
||||
})
|
||||
}
|
||||
|
||||
func (builder *historyBuilder) registerDocumentRoot(root *document.Node) {
|
||||
builder.requireOpen()
|
||||
if root != nil {
|
||||
builder.model.inventoryRoots = append(builder.model.inventoryRoots, root)
|
||||
}
|
||||
}
|
||||
|
||||
func (builder *historyBuilder) addInventoryObservation(path, reportedPath Path, payload historyPayloadRef, phase historyPhase, sensitive bool) int {
|
||||
return builder.addObservation(historyObservation{
|
||||
path: path, phase: phase, payload: payload,
|
||||
@@ -204,32 +195,40 @@ func (model *historyModel) documentRoots() []*document.Node {
|
||||
if model == nil {
|
||||
return nil
|
||||
}
|
||||
roots := append([]*document.Node(nil), model.inventoryRoots...)
|
||||
roots = append(roots, model.baseline, model.final)
|
||||
var roots []*document.Node
|
||||
appendRoot := func(root *document.Node) {
|
||||
if root != nil {
|
||||
roots = append(roots, root)
|
||||
}
|
||||
}
|
||||
appendRoot(model.baseline)
|
||||
appendRoot(model.final)
|
||||
for _, payload := range model.sourcePayloads {
|
||||
if payload.kind == historySourceApplicationPayload {
|
||||
roots = append(roots, payload.application.value)
|
||||
appendRoot(payload.application.value)
|
||||
}
|
||||
}
|
||||
for _, payload := range model.inheritancePayloads {
|
||||
for _, operation := range payload.operations {
|
||||
roots = append(roots, operation.parent, operation.effective)
|
||||
appendRoot(operation.parent)
|
||||
appendRoot(operation.effective)
|
||||
}
|
||||
}
|
||||
for _, payload := range model.cliPayloads {
|
||||
if payload.kind == historySourceApplicationPayload {
|
||||
roots = append(roots, payload.application.value)
|
||||
appendRoot(payload.application.value)
|
||||
}
|
||||
}
|
||||
if model.preCLICheckpoint != nil {
|
||||
roots = append(roots, model.preCLICheckpoint.root)
|
||||
appendRoot(model.preCLICheckpoint.root)
|
||||
}
|
||||
if model.postCLICheckpoint != nil {
|
||||
roots = append(roots, model.postCLICheckpoint.root)
|
||||
appendRoot(model.postCLICheckpoint.root)
|
||||
}
|
||||
if model.resolutionPayload != nil {
|
||||
for _, snapshot := range model.resolutionPayload.snapshots {
|
||||
roots = append(roots, snapshot.before, snapshot.after)
|
||||
appendRoot(snapshot.before)
|
||||
appendRoot(snapshot.after)
|
||||
}
|
||||
}
|
||||
return roots
|
||||
|
||||
Reference in New Issue
Block a user