-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix: preserve original YAML formatting in resource output #6046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
|
|
Welcome @Rindrics! |
|
Hi @Rindrics. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Rindrics The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
a86c62a to
3372098
Compare
Previously, Resource.AsYAML() used yaml.JSONToYAML which caused two issues:
1. Long lines were automatically wrapped at ~80 characters, breaking
shell commands and template strings (e.g., Helm-style {{ }})
2. Quote styles were inconsistently modified - sometimes removed,
sometimes added
This change switches to using kyaml's encoder (RNode.MustString) which
preserves the original YAML formatting, including:
- Long lines remain on a single line
- Quote styles ('single', "double", or unquoted) are preserved
This is a more consistent behavior that respects the user's original
YAML structure.
Related to:
- kubernetes-sigs#947
- kubernetes-sigs#3969
3372098 to
faaf4d2
Compare
What this PR does
Changes
Resource.AsYAML()to use kyaml's encoder instead ofsigs.k8s.io/yaml.JSONToYAML.Why
The previous implementation had issues with:
Breaking changes
Quote styles are now preserved instead of being normalized. For example:
'quoted_value'stays as'quoted_value'(previously becamequoted_value)This is considered an improvement as it provides consistent, predictable output.
Related to: