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

Have a go run compatible workflow

Open remyleone opened this issue 4 years ago • 3 comments

Currently, if I try to run the main.go directly with go I get the following errors. Could you have defaults such as undefined commit and devel version?

$ go run ./cmd/tfplugindocs/main.go
# command-line-arguments
cmd/tfplugindocs/main.go:13:34: undefined: version
cmd/tfplugindocs/main.go:14:5: undefined: commit
cmd/tfplugindocs/main.go:15:32: undefined: commit

remyleone avatar Dec 15 '20 09:12 remyleone

I think you just need to do go run ./cmd/tfplugindocs/ (without the main.go) so all the files in the package are included.

paultyng avatar Jan 26 '21 19:01 paultyng

# sieben @ sieben-macbook in ~/workspace/upstream/terraform-plugin-docs on git:main o [20:57:14]
$ go run ./cmd/tfplugindocs
go: downloading github.com/russross/blackfriday v1.6.0
rendering website for provider "terraform-plugin-docs"
exporting schema from Terraform
compiling provider "terraform-plugin-docs"
2021/01/26 20:57:33 error executing "/usr/local/bin/go", [go build -o /var/folders/58/dpfvy5xj6q5b44ly5zhfjfnh0000gn/T/tfws145824667/plugins/registry.terraform.io/hashicorp/terraform-plugin-docs/0.0.1/darwin_amd64/terraform-provider-terraform-plugin-docs]
2021/01/26 20:57:33 no Go files in /Users/sieben/workspace/upstream/terraform-plugin-docs
Error executing command: unable to generate website: error executing "/usr/local/bin/go": exit status 1

exit status 1

remyleone avatar Jan 26 '21 19:01 remyleone

It needs to run from the root working directory of a provider. Typically we do this using a go generate command, for example: https://github.com/hashicorp/terraform-provider-scaffolding/blob/bec212504f3fc7ad42e5f3a80425cb95872dda28/main.go#L18-L20

So if you wanted to test this from a provider, you would add this to your go.mod and use a replace directive to locate the files on disk. Does that make sense? I'll see if I can find an example of this, but it should at least be documented in this repo for folks to test/debug.

paultyng avatar Jan 26 '21 20:01 paultyng