Order CLI metadata history after inheritance
This commit is contained in:
@@ -24,17 +24,20 @@ func preparePostDecodeOverrideContext(input assembledInput, before decodedConfig
|
||||
after.origins = cloneOrigins(assigned.origins)
|
||||
after.final = document.Clone(assigned.final)
|
||||
|
||||
metadata := metadataFromDecoded(after)
|
||||
metadata := metadataFromDecoded(before)
|
||||
cliRecords := overrideMetadataRecords(before, assigned.overrides)
|
||||
var structuralOverlays []overlayRecord
|
||||
if input.inheritance != nil && input.composition != nil {
|
||||
structuralOverlays = input.composition.overlays
|
||||
applyInheritanceMetadata(&metadata, input.composition.root, input.composition.origins, append(cloneOverlayRecords(structuralOverlays), cliRecords...), input.inheritance)
|
||||
applyInheritanceMetadata(&metadata, input.composition.root, input.composition.origins, structuralOverlays, input.inheritance)
|
||||
} else if input.composition != nil {
|
||||
structuralOverlays = input.composition.overlays
|
||||
applyOverlayMetadata(&metadata, append(cloneOverlayRecords(structuralOverlays), cliRecords...))
|
||||
} else if len(cliRecords) != 0 {
|
||||
applyOverlayMetadata(&metadata, cliRecords)
|
||||
applyOverlayMetadata(&metadata, structuralOverlays)
|
||||
}
|
||||
if len(cliRecords) != 0 {
|
||||
metadata.fields = make(map[string]FieldInfo)
|
||||
collectFieldInfo(after.final, Path{}, after, metadata.fields)
|
||||
appendPostDecodeCLIHistory(&metadata, cliRecords)
|
||||
}
|
||||
|
||||
sources := cloneSourceInfos(input.sources)
|
||||
@@ -80,6 +83,21 @@ func preparePostDecodeOverrideContext(input assembledInput, before decodedConfig
|
||||
}
|
||||
}
|
||||
|
||||
// Source history is already assembled, with inheritance projected at query time.
|
||||
// Reuse overlay event construction for CLI changes without reapplying displaced
|
||||
// source definitions after those later assignments.
|
||||
func appendPostDecodeCLIHistory(metadata *Metadata, records []overlayRecord) {
|
||||
cli := Metadata{fields: metadata.fields}
|
||||
applyOverlayMetadata(&cli, records)
|
||||
for pointer, history := range cli.history {
|
||||
for _, change := range history {
|
||||
if change.Origin.Layer == LayerCLI {
|
||||
appendInputChangeEvent(metadata.history, nil, pointer, change)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func overrideMetadataRecords(before decodedConfiguration, overrides []preparedOverride) []overlayRecord {
|
||||
if len(overrides) == 0 {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user