-
Notifications
You must be signed in to change notification settings - Fork 69
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
cmd/generate: allow HasExample
and HasImport
to function
#155
cmd/generate: allow HasExample
and HasImport
to function
#155
Conversation
When building custom templates, we have `HasExample`[1] and `HasImport`[2] available that return a boolean value and allow templates to include conditionals. Some uses of this would be to only show either an example or import line should the files exist. However, when we are calling these for templates both data-sources and resources only pass in an empty string[3] resulting in the value always returning `false`[4]. This appears to be an oversight as the non-customisable render template call site correctly passes in the values[5] of these paths and the template expression renders. [1]: https://github.com/hashicorp/terraform-plugin-docs/blob/6e1a3339859e55625941bcef8ab365552235ca3b/internal/provider/template.go#L137 [2]: https://github.com/hashicorp/terraform-plugin-docs/blob/6e1a3339859e55625941bcef8ab365552235ca3b/internal/provider/template.go#L140 [3]: https://github.com/hashicorp/terraform-plugin-docs/blob/6e1a3339859e55625941bcef8ab365552235ca3b/internal/provider/generate.go#L420 [4]: https://github.com/hashicorp/terraform-plugin-docs/blob/e52e735a834db7cdbd980cc817989588c77d96d4/internal/provider/template.go#L198 [5]: https://github.com/hashicorp/terraform-plugin-docs/blob/6e1a3339859e55625941bcef8ab365552235ca3b/internal/provider/generate.go##L258
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 think this looks great, and it is yet another improvement to this tool that you are really helping to shape.
Can you please add the CHANGELOG section, describing the bugfix succinctly. I suspect this will be the first item in the v0.10.2
release.
thanks for the review! appreciate it 🤩 will pop a CHANGELOG entry in when I'm in front of a computer tomorrow morning. |
added a CHANGELOG entry with under "Unreleased" - feel free to update this when you know the release date. |
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.
LGTM
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
When building custom templates, we have
HasExample
andHasImport
available that return a boolean value and allow templatesto include conditionals. Some uses of this would be to only show either
an example or import line should the files exist. However, when we are
calling these for templates both data-sources and resources only pass in an
empty string resulting in the value always returning
false
.This appears to be an oversight as the non-customisable render template
call site correctly passes in the values of these paths and the template
expression renders.