hashicorp / hashicorp/go-plugin

Mechanism for fixed plugin sockets, for debug setups

Open
#206 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
6.1k
Forks
511
Avg merge
22h 47m
Merged PRs (30d)
4

Description

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:
* `TF_REATTACH_PROVIDERS` currently includes a PID number to check if the process is still alive, and otherwise error. This is cheatable by simply specifying an always-live PID like 1, but perhaps a cleaner solution is in order if this becomes an official configuration.
* You'll need to unlink() + recreate the Unix socket if the unix socket still exists on disk due to unclean shutdown, probably.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.