Conversation
Files whose first line is "---" lose the marker when the setter pipeline rewrites them, because kyaml's reader consumes it and its writer only separates the second and later documents in a stream. The result is a formatting change in every automated commit that touches such a file, and a lint failure in repositories that require the marker. Set PreserveDocStart on the screening reader so the marker survives the round trip. The option is new in kyaml and off by default; no other formatting behaviour changes. Signed-off-by: Alex Ausch <alex@ausch.name> Assisted-by: claude-code/claude-opus-5[1m]
This was referenced Sep 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft: blocked on a kyaml release. The option this sets does not exist in the vendored
sigs.k8s.io/kustomize/kyamlyet, so the build fails until kubernetes-sigs/kustomize#6294 merges and ships. I will rebase and bump the dependency then.Fixes #1094.
What this does
Sets
PreserveDocStart: trueon the screening reader ininternal/update/filereader.go, so a manifest whose first line is---keeps it after the setter pipeline rewrites the file.Why
kyaml's reader consumes a leading
---and its writer only separates the second and later documents in a stream, so the marker is lost on round trip. Every automated commit that touches such a file therefore carries an unrelated formatting change, and repositories whose YAML linters require the marker fail on the controller's own commits.This was reported as fluxcd/flux2#4435 and closed with "That's what kustomize kyaml does when it patches the YAML, nothing we can do about it". That was accurate — kyaml had no way to preserve it. kubernetes-sigs/kustomize#6294 adds one, off by default, mirroring the existing
PreserveSeqIndentoption this reader already sets; this change opts in.Tests
internal/update/testdata/setters/{original,expected}/marked.yamlnow begin with---, soTestUpdateWithSetterscovers the round trip throughUpdateWithSettersandkio.LocalPackageWriter.Verified locally against the kyaml branch with a temporary
replacedirective (not committed):go test ./internal/update/...passes.marked.yaml, expecting---and gettingapiVer.... The fixture change is not self-satisfying.make tidy fmt vet && make testcannot pass until the dependency is available; that gate will be run on the rebase.