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
No Schema Discovery when using Resource/Data-Source specific templates #139
Comments
this isn't just you; i'm also hitting this. somewhere between 0.5.1 and 0.9.0 something is now causing this individual resource templates to fail. i'm still trying to put together a test case to bisect. |
looks like there is more nuance here than "doesn't work with 0.9.0" as https://github.com/OctopusDeployLabs/terraform-provider-octopusdeploy works with individual resource templates and is using 0.9.0. still digging... |
narrowing this down further; |
here are my findings so far. to have individual templates rendered you need to:
will need to dig into why this is and doesn't meet the same criteria as the |
Oh. Interesting. Thanks for sharing. Still wonder if this is intended or
not. Seems as to not be intended.
…On Sun, Jun 12, 2022, 17:28 Jacob Bednarz ***@***.***> wrote:
here are my findings so far.
to have individual templates rendered you need to:
- use tfplugindocs directly, not tfplugindocs generate
- have the template filename wthout the provider name prefixed (i.e.
access_application.md.tmpl not cloudflare_access_application.md.tmpl
like when you want to copy the file verbatim.
will need to dig into why this is and doesn't meet the same criteria as
the tfplugindocs generate command as it also means you cannot pass in
configuration flags with the default commands.
—
Reply to this email directly, view it on GitHub
<#139 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEXNTRWZM7XF35WKAOWBB7DVOZ6C5ANCNFSM5WYIHR3A>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I wouldn't suspect it is intended. Now that I've found where it works, I can have a look into why this isn't working. |
After updating to 0.9.0, I found that individual template overrides no longer worked using the `generate` command however, would work if using `tfplugindocs` directly. I started looking into why this was and it boiled down to being that the value from `--rendered-provider-name` was being incorrectly passed into `resourceSchema` causing the friendly name (such as `Cloudflare`) to be used instead of the correct schema name (here, `terraform-provider-cloudflare`) resulting in the schema never being found for the data-source or resource. This corrects the value we pass to the render website methods to always be the schema provider, not the friendly name. Closes hashicorp#139
found the cause of this and addressed in #148; blame past Jacob. feel free to pull that locally and give it a whirl. |
After updating to 0.9.0, I found that individual template overrides no longer worked using the `generate` command however, would work if using `tfplugindocs` directly. I started looking into why this was and it boiled down to being that the value from `--rendered-provider-name` was being incorrectly passed into `resourceSchema` causing the friendly name (such as `Cloudflare`) to be used instead of the correct schema name (here, `terraform-provider-cloudflare`) resulting in the schema never being found for the data-source or resource. This corrects the value we pass to the render website methods to always be the schema provider, not the friendly name. Closes hashicorp#139
After updating to 0.9.0, I found that individual template overrides no longer worked using the `generate` command however, would work if using `tfplugindocs` directly. I started looking into why this was and it boiled down to being that the value from `--rendered-provider-name` was being incorrectly passed into `resourceSchema` causing the friendly name (such as `Cloudflare`) to be used instead of the correct schema name (here, `terraform-provider-cloudflare`) resulting in the schema never being found for the data-source or resource. This corrects the value we pass to the render website methods to always be the schema provider, not the friendly name. Closes hashicorp#139
After updating to 0.9.0, I found that individual template overrides no longer worked using the `generate` command however, would work if using `tfplugindocs` directly. I started looking into why this was and it boiled down to being that the value from `--rendered-provider-name` was being incorrectly passed into `resourceSchema` causing the friendly name (such as `Cloudflare`) to be used instead of the correct schema name (here, `terraform-provider-cloudflare`) resulting in the schema never being found for the data-source or resource. This corrects the value we pass to the render website methods to always be the schema provider, not the friendly name. Closes hashicorp#139
After updating to 0.9.0, I found that individual template overrides no longer worked using the `generate` command however, would work if using `tfplugindocs` directly. I started looking into why this was and it boiled down to being that the value from `--rendered-provider-name` was being incorrectly passed into `resourceSchema` causing the friendly name (such as `Cloudflare`) to be used instead of the correct schema name (here, `terraform-provider-cloudflare`) resulting in the schema never being found for the data-source or resource. This corrects the value we pass to the render website methods to always be the schema provider, not the friendly name. Closes #139
Hey Guys, Seems something still a miss here. Related to naming, I believe 0.10.0 is unable to find some resource it created itself. This provider doesn't have any actual template defined.. so tfplugindocs creates all the templates, then complains it can't find them.. Any thoughts?
I verified the md.tmpl files where created in the tmp directory. Any suggestions on how to trouble shoot this further? |
can you link me to your repository? I suspect the filename is incorrect and not matching what the schema expects for this resource as the others work just fine. |
Hi @jacobbednarz , thanks for the responses. Unfortunately I can't share a link to the repo. Not public yet, and its not mine to share. Should go public once I figure out how to finish the docs. However this is the directory/file structure that exists after running tfplugindocs version 0.10.0 You'll find I have a Directory: tmpls-notworking, where I'm keeping my intended, manually created, tmpls that were not working properly with schema discovery in 0.9.0. I was thinking the error is coming from not being able to find the template tfplugindocs created. But perhaps I'm thinking about the wrong file names aligning.
|
This issue is resolved in 0.10.1 #150 |
Not sure if I have the wrong expectation or if something is broken with resource and data-source templates. The template line:
{{ .SchemaMarkdown | trimspace }} seems to break/not-function when I create these specific templates.
I have my internal/provider/resource_plugin.go and internal/provider/datasource_plugin.go files defined. I create templates:
templates/resource/plugin.md.tmpl and templates/data-sources/plugin.md.tmpl
run tfplugindocs in the root of my plugin repo and get an error:
Error executing command: unable to generate website: unable to render template "data-sources/plugin.md.tmpl": unable to execute template: template: docTemplate:11:21: executing "docTemplate" at <trimspace>: invalid value; expected string
This trimspace error is related to .SchemaMarkdown return "". Seems that .SchemaMarkdown can't find the
func resourcePlugin() *schema.Resource
in resource_plugin.go (nor datasource_plugin.go).If I don't create specific templates, tfplugindocs runs to completion and all the files are generated. Although without the custom content I'd like to include.
I'm expecting my specific templates to allow me to create custom md-headers and other content, while .SchemaMarkdown does it's thing.
Creating the specific template index.md.tmpl works as I expect.
Is this how templates/resource/plugin.md.tmpl and templates/datasources/plugin.md.tmpl are suposed to work?
Thank you.
The text was updated successfully, but these errors were encountered: