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

tfvars --output-file terraform.tfvars inserts comments which make output file invalid #710

Open
jonathanperret opened this issue Sep 18, 2023 · 0 comments
Labels

Comments

@jonathanperret
Copy link

Describe the bug

When running terraform-docs tfvars --output-file terraform.tfvars to generate a variables file, terraform-docs inserts a <!-- BEGIN_TF_DOCS --> comment at the start of the output file (regardless of whether the output is requested in JSON or HCL), and a <!-- END_TF_DOCS --> line at the end, which make the variables file invalid.

I'd expect terraform-docs tfvars --output-file terraform.tfvars to generate the expected content without inserting comments before and after it.

How can we reproduce it?

  • Enter an empty directory.
  • Run terraform-docs tfvars --output-file terraform.tfvars hcl ., or terraform-docs tfvars --output-file terraform.tfvars.json json .. The output says terraform.tfvars[.json] updated successfully.
  • Open the resulting terraform.tfvars[.json] file and observe that it contains HTML comments making it syntactically invalid.

Suggested workaround

Adding --output-mode replace --output-template '{{ .Content }}' to the command line correctly generates a well-formed variables file.

Environment information

  • terraform-docs version: terraform-docs version v0.16.0 1f686b1 darwin/arm64
  • OS : macOS 13.5.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant