-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
terraform fmt changes Windows line endings to Unix #32910
Comments
Hi @bucs-fan813,
In an ideal world the underlying grammar HCL would've already been normalizing the line endings of heredocs so that they are always the same regardless of how the source file is written, so that LF and CRLF would be entirely equivalent in all cases and Another option then would be to change the HCL formatter that Another option would be for I'm not sure what the best answer is. Any change to the existing line endings in a heredoc could potentially cause a problem, but not changing line endings elsewhere in the document could potentially also be problematic if they weren't already consistent. Perhaps the sweet spot is for the formatter to first check whether the existing file is 100% using Windows-style line endings, and only if that is true then rewrite the output to also use CRLF instead of LF exclusively. In all other cases it would behave as it does today, changing all of the line endings to LF so that the result is at least consistent. The edge case here is if the input is already using inconsistent line endings (a mixture of CRLF and LF), which we'd arbitrarily decide is normalized to all of them being LF because that matches how it already behaves in that case and thus it limits the potential churn caused by the change. |
* Fix `nodeadm` example typo * `apiVersion: node.eks.aws/v1alpha` -> `apiVersion: node.eks.aws/v1alpha1` * Revert whitespace changes * `tofu apply` in `examples/user_data` * chore: Fix file extension type for MIME multipart user data * chore: Fix line endings based off this hashicorp/terraform#32910 --------- Co-authored-by: Bryant Biggs <[email protected]>
+1 |
Terraform Version
Terraform Configuration Files
N/A
Debug Output
N/A
Expected Behavior
terraform fmt
should produce files that are compliant with the configured provider(s)Actual Behavior
trailing whitespace.git-diff-check(error) and/or unexpected EOF error.
Steps to Reproduce
terraform init
terraform fmt
terraform apply
Additional Context
It would be nice if
terraform fmt
could allow for formatting files in accordance with other popular linters (besides tflint) like trunk for VSCode. The obvious workaround# trunk-ignore-all(git-diff-check)
only kicks the can down the road. Developers may spend a considerable amount of time troubleshooting line terminations in herdoc blocks since it won't be obvious when/where certain tf resources (like aws lambda and codebuild) have unexpected EOF errors. For windows vscode users,Remote extensions:connect to wsl
will also help but on larger teams this also only kicks the can. I'm new to terraform but it seems this issue has been mentioned previously. I tried making a fix for it myself but I'm not familiar enough with go or terraform to be able to test a PR. This may be better suited as a provider parameter since this use case may not apply to azure or other providers?References
The text was updated successfully, but these errors were encountered: