-
Notifications
You must be signed in to change notification settings - Fork 661
yqutil: fix to preserve line breaks #2625
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
yqutil: fix to preserve line breaks #2625
Conversation
`yamlfmt` works by replacing line breaks with place holder strings to avoid their loss when using `gopkg.in/yaml.v3`. By replacing line breaks with place holder strings before `yqlib` uses `gopkg.in/yaml.v3`, we can ultimately prevent the loss of line breaks through `yamlfmt`. Signed-off-by: Norio Nomura <[email protected]>
…nothing)'` `find examples -name '*.yaml' -exec limactl edit --set 'del(.nothing)' {} \;` Signed-off-by: Norio Nomura <[email protected]>
Signed-off-by: Norio Nomura <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs more comments and acknowledgement of the copied upstream code.
contentModified, err := replaceLineBreaksWithMagicString(content) | ||
if err != nil { | ||
return nil, err | ||
} | ||
tmpYAMLFile, err := os.CreateTemp("", "lima-yq-*.yaml") | ||
if err != nil { | ||
return nil, err | ||
} | ||
tmpYAMLPath := tmpYAMLFile.Name() | ||
defer os.RemoveAll(tmpYAMLPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is not part of this PR, but why is this calling os.RemoveAll()
instead of os.Remove()
given that tmpYAMLPath
is a file and not a directory.
@afbjorklund Do you remember why you choose RemoveAll
?
Signed-off-by: Norio Nomura <[email protected]>
Signed-off-by: Norio Nomura <[email protected]>
7884213
to
f2d6a55
Compare
I rewrote it to avoid relying on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM
Thanks! 🙏🏻 |
yamlfmt
works by replacing line breaks with place holder strings to avoid their loss when usinggopkg.in/yaml.v3
. By replacing line breaks with place holder strings beforeyqlib
usesgopkg.in/yaml.v3
, we can ultimately prevent the loss of line breaks throughyamlfmt
.#2593 (comment)