hashicorp / go-plugin

Golang plugin system over RPC.
Mozilla Public License 2.0
5.25k stars 450 forks source link

Mechanism for fixed plugin sockets, for debug setups #206

Open PJB3005 opened 2 years ago

PJB3005 commented 2 years ago

This issue is mostly in the context of terraform but it seems the best way to tackle it is at the bottom of the stack, so I'm posting it here.

Right now, Terraform requires me to manually copy paste the TF_REATTACH_PROVIDERS environment configuration every time I start my provider in a debugger. This is really inconvenient. As far as I can tell there is currently no clean way around this, since Unix sockets are always assigned a random temp file, and I'd rather not have some hacky concoction of env vars and command aliases to prefix me running terraform with something to load the provider config automatically.

It seems to me like the best solution is some sort of env var to force the plugin system to mount to a specific unix (or TCP for Windows, but btw Windows 10 has had unix sockets for almost 5 years now) socket. Then I can specify a fixed TF_REATTACH_PROVIDERS and pressing F5 in VSCode is all I need to make sure the provider is properly connected to the terraform CLI.

Some further thoughts: