Skip to content
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

Optional CRLF line endings #722

Open
timothy-mcroy opened this issue Nov 23, 2023 · 2 comments · May be fixed by #723
Open

Optional CRLF line endings #722

timothy-mcroy opened this issue Nov 23, 2023 · 2 comments · May be fixed by #723

Comments

@timothy-mcroy
Copy link

What problem are you facing?

terraform-docs always generates LF endings. When running terraform-docs --output-check when a README was downloaded from a VCS with CRLF line endings, this output check fails. This means that any post commit checks that run with CRLF checkouts cannot properly verify the output with --output-check, because the line endings are inconsistent with what terraform-docs is hardcoded to produce.

We are using terraform-docs on windows in a situation where having the files checked out with CRLF is preferable. We're configuring windows systems and that consistency in tooling is preferable over using linux runners for this one aspect of our tech stack.

How could terraform-docs help solve your problem?

Add a flag to use CRLF line endings in the output README. This will allow anyone facing as similar problem to specify the expected line endings for any VCS.

@timothy-mcroy timothy-mcroy linked a pull request Nov 23, 2023 that will close this issue
2 tasks
@rquadling
Copy link

rquadling commented Dec 29, 2023

Interesting issue. One that I came across before. The npm-ini package has a similar issue related to generating INI files (npm/ini@6a3cb38).

Their solution was to use define line endings based upon detecting of the OS, but allow the override if required.

Is that a "better" option? If you are on a Windows environment, it is pretty much a standard thing that the files will be made with CRLF, and so, having to set an option for the expected default behaviour would seem a bit odd.

As the binaries are built for different operating systems, is it acceptable to have the default value for line endings based upon the target OS?

I'm not a go expert, and so whilst this idea may be fine for npm-ini, it may not be "how things are done" in Go apps.

@timothy-mcroy
Copy link
Author

That would require that everyone executing terraform-docs does so from the same OS as well as having the same vcs client configurations, right? Any contributor for my terraform project who used windows when we're on *nix or vice-versa would generate docs that flip the line endings. Plus, you can only run terraform docs --output-check as part of your CI process with one OS, so flipping between them isn't nice either. And that's not really backward compatible, since however many windows clients would suddenly start using CRLF line endings with little explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants