27 lines
930 B
Go
27 lines
930 B
Go
package config
|
|
|
|
import configkit "gitea.maximumdirect.net/eric/ConfigKit"
|
|
|
|
// documentNormalizer records leaf provenance and, while visiting a sequence,
|
|
// covers its atomic mutation boundary. ConfigKit audits sequences as whole
|
|
// values, so a record for only a descendant is insufficient. The outermost
|
|
// sequence covers nested sequences as well; unchanged visits record nothing.
|
|
type documentNormalizer struct {
|
|
*configkit.Resolution
|
|
sequence *configkit.Path
|
|
}
|
|
|
|
func (n documentNormalizer) inSequence(path configkit.Path) documentNormalizer {
|
|
if n.sequence == nil {
|
|
n.sequence = &path
|
|
}
|
|
return n
|
|
}
|
|
|
|
func (n documentNormalizer) Record(path configkit.Path, kind configkit.ChangeKind, reason string, dependencies ...configkit.Path) {
|
|
n.Resolution.Record(path, kind, reason, dependencies...)
|
|
if n.sequence != nil {
|
|
n.Resolution.Record(*n.sequence, kind, reason, append([]configkit.Path{path}, dependencies...)...)
|
|
}
|
|
}
|