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

+12
View File
@@ -43,6 +43,18 @@ func UnknownKeys(raw []byte, schema any) ([]UnknownKey, error) {
return out, nil
}
// UnknownKeysNode is UnknownKeys for an already parsed mapping node
// (e.g. one section of a larger file): keys are reported relative to n,
// with their line in the original document.
func UnknownKeysNode(n *yaml.Node, schema any) []UnknownKey {
if n == nil || n.Kind != yaml.MappingNode || schema == nil {
return nil
}
var out []UnknownKey
walkUnknown(nil, reflect.TypeOf(schema), n, &out)
return out
}
// UnknownKeysFile is UnknownKeys for the file at path.
func UnknownKeysFile(path string, schema any) ([]UnknownKey, error) {
raw, err := os.ReadFile(path)