terraform-plugin-docs icon indicating copy to clipboard operation
terraform-plugin-docs copied to clipboard

Log/Output Provider Binary Path When Used

Open tekumara opened this issue 3 years ago • 3 comments

example:

// service_account resource schema
func (r serviceAccountResourceType) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) {
	return tfsdk.Schema{

		MarkdownDescription: "Service account resource",

		Attributes: map[string]tfsdk.Attribute{
			"id": {
				Type:     types.StringType,
				Computed: true,
				MarkdownDescription: "Server generated UUID",
			},
			"name": {
				Type:     types.StringType,
				Required: true,
				Validators: []tfsdk.AttributeValidator{
					validate.StringNotNull(),
				},
			},
			"role": {
				Type:     types.StringType,
				Required: true,
				Validators: []tfsdk.AttributeValidator{
					validate.RoleIsValid(),
				},
			},
			"membership_id": {
				Type:     types.StringType,
				Computed: true,
				MarkdownDescription: "Server generated UUID",
			},
		},
	}, nil
}

Both Description and MarkdownDescription are ignored.

github.com/hashicorp/terraform-plugin-docs v0.5.1

tekumara avatar Mar 14 '22 03:03 tekumara

Hi @tekumara 👋 Thank you for raising this and sorry you ran into trouble here.

I'm not able to reproduce this using the main branch of terraform-provider-scaffolding-framework. I verified the functionality by updating the descriptions of the resource and an attribute, running go generate ./..., then verifying the output Markdown files were updated.

I'm curious if you might have run into one of the following:

  • #122, which would've temporarily prevented the tfplugindocs tool from working with the terraform-plugin-sdk v2.11.0 release on Friday. This is fixed with v0.6.0 released today.
  • The provider codebase missing a comment such as //go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs (or some human or other process running the underlying tfplugindocs command)

If everything is up to date and something is executing the tfplugindocs command, please feel free to open with additional details for how to reproduce this issue and we can take a fresh look. 👍

bflad avatar Mar 14 '22 20:03 bflad

Thanks @bflad I've done some more digging ...

So when I run terraform providers schema -json I can see that my provider attributes have a description field but my resources have none. So tfplugindocs has nothing to work with.

I think what's happening is that tfplugindocs, regardless whether its run via go generate or go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs is using the last installed version of my provider in $GOBIN rather than my source. My last installed version was out of date and didn't have the description field changes I made 😥.

So instead, I'll make sure I rebuild and install my provider into $GOBIN first and then generate the docs. 😄

tekumara avatar Mar 15 '22 02:03 tekumara

@tekumara this is great information and seems like this behavior should be better documented or the tool should provide some additional logging that mentions which provider binary might be in use. I'm going to reopen this to explore this further. Thanks for the followup!

bflad avatar Mar 15 '22 12:03 bflad