Skip to content

Split YAML documents with the Kubernetes YAML reader - #56

Open
MPV wants to merge 1 commit into
claude/skip-non-workloadsfrom
claude/robust-yaml-splitting
Open

Split YAML documents with the Kubernetes YAML reader#56
MPV wants to merge 1 commit into
claude/skip-non-workloadsfrom
claude/robust-yaml-splitting

Conversation

@MPV

@MPV MPV commented Jul 23, 2026

Copy link
Copy Markdown
Owner

What

Replace bytes.Split(data, []byte("\n---\n")) with apimachinery's YAMLReader via a new yamlparser.ProcessReader that streams documents from an io.Reader. Both the file and stdin paths read through it.

Why

Splitting on the literal "\n---\n" missed:

  • a leading --- separator,
  • separators followed by trailing whitespace,
  • CRLF line endings,
  • a final document with no trailing newline.

Behavior change

Documents separated in any of those ways are now parsed correctly. The file and stdin paths share one splitting implementation, so they behave identically.

Testing

Added TestProcessReader covering each of the edge cases above; the obsolete processDocuments helper test is removed. go.mod/go.sum are unchanged (the reader lives in the already-required apimachinery module).

Stack

Third of the parsing stack. Base: claude/skip-non-workloads (#54). Merge order: #49#54 → this.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Pc6NAURAqjU4LYJx93tgSC


Generated by Claude Code

@MPV
MPV force-pushed the claude/skip-non-workloads branch from e896ac0 to 82b2362 Compare July 23, 2026 07:09
@MPV
MPV force-pushed the claude/robust-yaml-splitting branch from 9941ad2 to 1fb8717 Compare July 23, 2026 07:09
@MPV
MPV force-pushed the claude/skip-non-workloads branch from 82b2362 to aad8d56 Compare July 23, 2026 08:17
@MPV
MPV force-pushed the claude/robust-yaml-splitting branch 2 times, most recently from 7d70b66 to dd5529b Compare July 23, 2026 08:24
@MPV
MPV force-pushed the claude/skip-non-workloads branch from aebe427 to ab391dc Compare July 24, 2026 06:45
@MPV
MPV force-pushed the claude/robust-yaml-splitting branch from dd5529b to 324f980 Compare July 24, 2026 06:45
@MPV
MPV force-pushed the claude/skip-non-workloads branch from ab391dc to 050d1ab Compare August 2, 2026 08:00
Document splitting used bytes.Split on the literal "\n---\n", which
missed a leading "---" separator, separators with trailing whitespace,
CRLF line endings, and a final document with no trailing newline.

Replace it with apimachinery's YAMLReader via a new
yamlparser.ProcessReader that streams documents from an io.Reader. Both
the file and stdin paths now read through it, so their splitting behaves
identically and correctly across these cases.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pc6NAURAqjU4LYJx93tgSC
@MPV
MPV force-pushed the claude/robust-yaml-splitting branch from 324f980 to 129d31d Compare August 2, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants