Hi
I’m working with a Vault Plugin. And I’m having some errors and it will much more easy to debug the code of the plugin with VS CODE. I could not found any way or tutorial. Is there some way?
Regards,
Mariano
Hi
I’m working with a Vault Plugin. And I’m having some errors and it will much more easy to debug the code of the plugin with VS CODE. I could not found any way or tutorial. Is there some way?
Regards,
Mariano
The plugin is a process that is spawned by Vault. To debug it, you must attach to it. But Vault actually launches the plugin twice. First time is to get some metadata about it (I guess). The second run is a lazy load when required.
I use Delve to debug. I am used to debug on the command line, in black and white (just like my hair color).
With that knowledge in hand, here is how I debug my plugin. YMMV.
ptrace
.go build -o vault/plugins/myplugin -gcflags "all=-N -l" cmd/myplugin/main.go
seal_wrap
. I do something like this:
vault secrets disable myplugin
vault plugin deregister myplugin
vault plugin register --sha256=$(sha256sum vault/plugins/myplugin|cut -f1 -d " ") myplugin
vault list myplugin/path/load-me
. Path resolution is done by your plugin so the path does not need to existdlv attach $(pgrep myplugin)
func myplugin.*
b myplugin.my_function_I_want_to_debug
c
Then run a command that will trigger that breakpoint. Set/Export a large VAULT_CLIENT_TIMEOUT to your environment because you might end up looking at your code at the breakpoint for more than the default 60 seconds.