Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MergeConfigStack ¶ added in v0.2026250.632
func MergeConfigStack(system, user, project *spec.UnifiedFile, systemDir, userDir, projectDir string) *spec.UnifiedFile
MergeConfigStack merges the layered config stack (system → user → project) into one spec.UnifiedFile, LATER files winning (project > user > system).
Each layer is a plain UnifiedFile: the system layer (/etc/charly/charly.yml), the user layer (~/.config/charly/charly.yml), and the in-dir project layer (<project>/charly.yml). The merge reuses MergeUnified (dst-wins) with the LATER file as dst, so a node or field declared in a later layer overrides the earlier one, and earlier-only declarations survive as gaps the later layer fills.
Each layer's Discover specs are pre-anchored to that layer's OWN directory (spec.AnchorScanSpecs) BEFORE merging, so MergeUnified's srcDir re-anchoring is a no-op (AnchorScanSpecs passes absolute paths through unchanged) and a system-layer discover root stays anchored to the system dir rather than to the project dir.
Each layer is copied before merging — the caller's files are never mutated. Nil layers are skipped.
func MergeUnified ¶
func MergeUnified(dst, src *spec.UnifiedFile, srcDir string)
MergeUnified merges src into dst such that dst's existing values WIN on conflict at the same leaf (root-wins). This means when MaterializeLoadedProject replays the walk's documents in order (the root file first, then its flat imports), the root file's values are already present before any import's fields are considered, so root wins.
For included files: the same MergeUnified is called but dst already contains the root's values, so those fields stay untouched. src's fields that aren't present in dst get copied over. That's the desired semantics.
Types ¶
This section is empty.