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
Trailing space on output.template
start/end comments results in Error: value of '--output-template' is missing end comment
#652
Comments
@ccampo133 I found the issue - the docs' example code has trailing spaces following |
Upon further inspection, it's not a fault in the documentation as it's written. It's an issue with how the code blocks are rendered on terraform-docs.io. If you copy the contents from the site, it includes a lot of trailing spaces: However, the code itself doesn't actually have trailing spaces. This appears to only be an issue with HTML comment blocks, not anything else. This has to do with how the site is rendered and I have no clue how to work with that. Hopefully this helps people figure out this problem, at least. |
@ccq1994 confirmed that removing the trailing spaces does appear to resolve the issue I reported. Thanks for tracking that down! I think it would make sense to have the code ignore/trim any whitespace following the comment. |
I opened a PR for this here: #658 |
If you intent to write a newline after If the newline is missing, this is something that git clients will tell you about, like explained here: https://stackoverflow.com/questions/5813311/whats-the-significance-of-the-no-newline-at-end-of-file-log |
@nikolaik yes, although I'm not sure that your question is relevant to this issue. The template in question here must be passed in the YAML file, under the
formatter: "markdown"
output:
file: "README.example.md"
template: |-
<!-- BEGIN_TF_DOCS -->
{{ .Content }}
<!-- END_TF_DOCS -->
mode: inject |
@EppO @blakegong @khos2ow any chance this issue and corresponding PR could be merged? Or is this project unmaintained at this point? |
output.template
results in Error: value of '--output-template' is missing end comment
output.template
start/end comments results in Error: value of '--output-template' is missing end comment
is the related fix going to be merged ? @EppO @blakegong @khos2ow |
@RuiSMagalhaes I'd love to see it merged, but I don't think the project is actively maintained. However the workaround for now is simple - just to remove any extra whitespace from the template manually (see #652 (comment)). |
Describe the bug
Specifying theoutput.template
value as a YAML multiline block in.terraform-docs.yml
string results in the errorError: value of '--output-template' is missing end comment
, despite the end comment clearly existing.See edit at the bottom for clarification. This appears to be caused by extra whitespace around these comments.
If you specify as a regular quoted string with linebreaks, it works as expected (no error).
How can we reproduce it?
Pretty simple to reproduce. Create the following files:
main.tf
:.terraform-docs.yml
:And you'll see the following error:
See my example repo: https://github.com/ccampo133/terraform-docs-template-comment-bug
EDIT 2022-12-13:
As identified by @ccq1994 in this comment, it appears to be caused by trailing whitespace after the
<!--END_TF_DOCS -->
comment. Looking further in the code at https://github.com/terraform-docs/terraform-docs/blob/master/print/config.go#L292-L293, the whitespace of these lines are intentionally trimmed anyway, however this happens after validation is performed. I opened #658 to address this.Environment information
terraform-docs version v0.16.0 darwin/amd64
MacOS Monterey 12.6
The text was updated successfully, but these errors were encountered: