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

tfplugindocs does not handle tags

Open abergmeier opened this issue 3 years ago • 3 comments

I have a Terraform Provider which needs special tags to build. These tags I can pass to:

go run -tags containers_image_openpgp github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs

The problem is though, that tfplugindocs does not pass along the tags. As a result tflugindocs fails building Go files.

Error: /home/runner/go/pkg/mod/github.com/containers/image/[email protected]/signature/mechanism_gpgme.go:17:16: undefined: gpgme.Context Error: /home/runner/go/pkg/mod/github.com/containers/image/[email protected]/signature/mechanism_gpgme.go:67:44: undefined: gpgme.Context Error: /home/runner/go/pkg/mod/github.com/containers/image/[email protected]/signature/mechanism_gpgme.go:68:14: undefined: gpgme.New Error: /home/runner/go/pkg/mod/github.com/containers/image/[email protected]/signature/mechanism_gpgme.go:72:27: undefined: gpgme.ProtocolOpenPGP Error: /home/runner/go/pkg/mod/github.com/containers/image/[email protected]/signature/mechanism_gpgme.go:76:28: undefined: gpgme.ProtocolOpenPGP Error: /home/runner/go/pkg/mod/github.com/containers/image/[email protected]/signature/mechanism_gpgme.go:98:20: undefined: gpgme.NewDataBytes Error: /home/runner/go/pkg/mod/github.com/containers/image/[email protected]/signature/mechanism_gpgme.go:127:20: undefined: gpgme.NewDataBytes Error: /home/runner/go/pkg/mod/github.com/containers/image/[email protected]/signature/mechanism_gpgme.go:132:18: undefined: gpgme.NewDataWriter Error: /home/runner/go/pkg/mod/github.com/containers/image/[email protected]/signature/mechanism_gpgme.go:136:25: undefined: gpgme.Key Error: /home/runner/go/pkg/mod/github.com/containers/image/[email protected]/signature/mechanism_gpgme.go:136:61: undefined: gpgme.SigModeNormal Error: /home/runner/go/pkg/mod/github.com/containers/image/[email protected]/signature/mechanism_gpgme.go:136:61: too many errors

Thus I would need a way for tfplugindocs to handle tags when generating code.

abergmeier avatar Dec 18 '21 21:12 abergmeier

Given the current code structure and that it does not appear that Go exposes build tags during runtime, it seems this would require a new CLI flag that gets threaded through to the build call.

bflad avatar Dec 23 '21 17:12 bflad

seems this would require a new CLI flag that gets threaded through to the build call.

And IMO this would be preferable since once you have to use build tags I would expect that you KnowWhatYouAreDoing™. The corner case might be though, where a valid compilation gets produced with or without certain build tags.

Anyway - I started a naive implementation here: https://github.com/hashicorp/terraform-plugin-docs/pull/103. Comments very welcome.

abergmeier avatar Dec 23 '21 19:12 abergmeier

this would be much appreciated. Is there any workaround?

Soneca-ii avatar Nov 29 '22 09:11 Soneca-ii