config: Merge with per-value origins; configcmd: UnknownKeysNode

config.Merge(sources...) overlays explicit, ordered sources with the
LoadMerged rules (LoadMerged now uses the same code) and returns the
origin of every leaf, for a "config show" that says where each value
is set. config.ReadFile reads one file as a mapping, Resolver.Paths()
exposes the core/paths resolver (e.g. DataDir for defaults).
configcmd.UnknownKeysNode checks one section of a parsed document.
Needed by the yamase family's layered configuration (yamase ADR-0074).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
terminarandClaude Opus 5.5 committed 2026-10-25 14:57:50 +01:00
1 parent b7f7ba6b36
commit 185211e304
7 files changed
+262 -13

No files matched your search

+15
View File
@@ -109,3 +109,18 @@ func TestWarnUnknownAndCheck(t *testing.T) {
t.Errorf("clean file: %v %q", ok, note)
}
}
func TestUnknownKeysNode(t *testing.T) {
var doc yaml.Node
if err := yaml.Unmarshal([]byte("other: 1\nsection:\n log-level: info\n log-levle: debug\n"), &doc); err != nil {
t.Fatal(err)
}
section := doc.Content[0].Content[3]
got := UnknownKeysNode(section, testConfig{})
if len(got) != 1 || got[0].Key != "log-levle" || got[0].Line != 4 {
t.Errorf("UnknownKeysNode = %v, want log-levle on line 4 (relative key, document line)", got)
}
if got := UnknownKeysNode(nil, testConfig{}); got != nil {
t.Errorf("UnknownKeysNode(nil) = %v", got)
}
}