Skip to main content

VPlugin Usage

You need to register gobs from valkyrie

// Need to register types used for coms
vplugin.RegisterGobs()

In the plugin main method you need to setup a map of plugins. YourPlugin needs to implement the vplugin.PAM interface.

// pluginName needs to match "type" from configuration
var pluginMap = map[string]plugin.Plugin{
"pluginName": &vplugin.VPlugin{Impl: YourPlugin{}},
}

And then serve the plugin.

plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: handshakeConfig,
Plugins: pluginMap,
})
tip

The plugin.ServeConfig can also take a Logger. Read hashicorp/go-plugin documentation for more information.

package main

import(
"github.com/hashicorp/go-plugin"
"github.com/valkyrie-fnd/valkyrie/pam/vplugin"
)
var handshakeConfig = plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: vplugin.MagicCookieKey,
MagicCookieValue: vplugin.MagicCookieValue,
}
func main(){
vplugin.RegisterGobs()
// pluginMap is the map of plugins we can dispense.
// pluginName needs to match "type" from configuration
var pluginMap = map[string]plugin.Plugin{
"pluginName": &vplugin.VPlugin{Impl: YourPlugin{}},
}

plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: handshakeConfig,
Plugins: pluginMap,
})
}