fix(09): WR-07 keep relation column order from the YAML itself, not a fixed indentation

This commit is contained in:
Jakub Zych
2026-10-01 21:10:09 +02:00
parent 889250c8fb
commit b026aec162
3 changed files with 80 additions and 22 deletions

View File

@@ -18,6 +18,14 @@ func decodeStrict(raw []byte, dest any) error {
return nil
}
// decodeStrictOrdered is decodeStrict with every nested mapping kept as an
// ordered yaml.MapSlice, so a file that is decoded, re-marshalled per entry and
// decoded again keeps its key order at any depth and any indentation.
func decodeStrictOrdered(raw []byte, dest any) error {
dec := yaml.NewDecoder(bytes.NewReader(raw), yaml.DisallowUnknownField(), yaml.UseOrderedMap())
return dec.Decode(dest)
}
func readAsset(fsys fs.FS, name string) ([]byte, error) {
name = path.Clean(name)
if name == "." || strings.HasPrefix(name, "..") || strings.Contains(name, "..") {