Documentation
¶
Overview ¶
Package shared provides shared functionality for Privateer plugins.
Index ¶
Constants ¶
const ( TestPass = iota TestFail Aborted InternalError BadUsage NoTests )
Canonical exit codes. Defined here so command/ and pluginkit/ can both reference them without an import cycle.
const PluginName = "plugin"
PluginName is used by Privateer Core sally.go: rpcClient.Dispense(plugin.PluginName).
Variables ¶
This section is empty.
Functions ¶
func GetHandshakeConfig ¶
func GetHandshakeConfig() hcplugin.HandshakeConfig
GetHandshakeConfig provides handshake config details. It is used by core and service packs.
Types ¶
type Plugin ¶
type Plugin struct {
// Impl is the plugin implementation.
Impl Pluginer
}
Plugin is the implementation of plugin.Plugin so we can serve/consume this.
This has two methods: Server must return an RPC server for this plugin type. We construct a PluginRPCServer for this.
Client must return an implementation of our interface that communicates over an RPC client. We return PluginRPC for this.
Ignore MuxBroker. That is used to create more multiplexed streams on our plugin connection and is a more advanced use case.
type PluginRPC ¶
type PluginRPC struct {
// contains filtered or unexported fields
}
PluginRPC is an implementation that talks over RPC.
type PluginRPCServer ¶
type PluginRPCServer struct {
// Impl is the real implementation.
Impl Pluginer
}
PluginRPCServer is the RPC server that PluginRPC talks to, conforming to the requirements of net/rpc.
func (*PluginRPCServer) Start ¶
func (s *PluginRPCServer) Start(args interface{}, resp *StartResponse) error
Start is a wrapper for interface implementation.
type Pluginer ¶
Pluginer is the interface that we're exposing as a plugin. Start returns a privateer exit code (TestPass, TestFail, InternalError, BadUsage) and an optional error for diagnostic logging. Typed errors do not survive net/rpc, so classification must happen on the plugin side — see pluginkit.ExitCodeFor.
type ServeOpts ¶
type ServeOpts struct {
// Plugin is the interface implementation.
Plugin Pluginer
// Logger is the logger that go-plugin will use.
Logger hclog.Logger
}
ServeOpts are the configurations to serve a plugin.