fix: #177 use rendered provider name in default template#178
fix: #177 use rendered provider name in default template#178Fuochi wants to merge 1 commit intohashicorp:mainfrom
Conversation
| ` + frontmatterComment + ` | ||
| page_title: "{{.ProviderShortName}} Provider" | ||
| {{- $name := .ProviderShortName}} | ||
| {{- if ne .ProviderName .RenderedProviderName }}{{ $name = .RenderedProviderName}}{{ end }} |
There was a problem hiding this comment.
i believe the logic is incorrect here as this will always attempt to use .RenderedProviderName since .ProviderName is always going to differ from .RenderedProviderName.
i think what want is more like this:
{- $name := .ProviderShortName}}
{{- if .RenderedProviderName }}{{ $name = .RenderedProviderName }}{{ end }}
page_title: "{{ $name }} Provider"
(this is also more explicit by checking if the rendered provider name value is set, not just different)
There was a problem hiding this comment.
I think .RenderedProviderName is always set, and its default value is .ProviderName. Here's the reference:
terraform-plugin-docs/internal/provider/generate.go
Lines 123 to 125 in 2f535d3
Feel free to try it out!
There was a problem hiding this comment.
@jacobbednarz have you had the chance to check again?
There was a problem hiding this comment.
i haven't, however, being explicit in the template makes this clear what the expected outcome is instead of relying on overrides within the generation process.
There was a problem hiding this comment.
I totally agree! Actually, the solution you proposed was the first one that came to my mind as well. Unfortunately, it just doesn't work because the .RenderedProviderName is never unset, as shown in the previous comment.
Thus, this PR will keep the default behaviour the same as it was before, and it overrides the provider name in the template only if the specific variable has been set.
5ef5342 to
ed269f3
Compare
ed269f3 to
d78a366
Compare
d78a366 to
925bfc4
Compare
925bfc4 to
d146b3c
Compare
|
👀 |
|
Hi @SBGoods. No problem, happy to see that finally this has been addressed and this repo is still maintained by someone! |
This is to solve #177 as suggested here: #177 (comment)
If --rendered-provider-name is set, the default template will use it. If not, it will continue to use previous value