mirror of
https://github.com/yannh/kubeconform.git
synced 2026-06-29 00:10:45 +00:00
FromStream set each Resource's Bytes to scanner.Bytes(), which aliases the bufio.Scanner's internal buffer. Resources are emitted on a channel and retained/parsed by the consumer concurrently with the producer goroutine; when the scanner refills its buffer for later documents it overwrites the slices earlier Resources still point at. Consumers that parse resources as they arrive (e.g. ValidateWithContext) then read corrupted bytes — a later document spliced into the one being parsed — surfacing as non-deterministic YAML parse errors on large multi-document streams (a different resource fails on each run). Clone the scanner bytes so each Resource owns its slice. Adds a regression test that streams >4MB (forcing the scanner to refill) and asserts every resource's bytes are intact after draining. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| cache | ||
| config | ||
| loader | ||
| output | ||
| registry | ||
| resource | ||
| validator | ||