Documentation
¶
Overview ¶
Package plugin orchestrates the plugin relationship between rules and the tfvet process
It uses hashicorp's go-plugin which implements a local client/server relationship with plugins and allows communication to the plugins over grpc.
To read more about hashicorp's plugin system see here: https://github.com/hashicorp/go-plugin/blob/master/docs/internals.md
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Handshake = plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "TFVET_PLUGIN",
MagicCookieValue: "26pGPy",
}
Handshake is a common handshake that is shared by plugin and host. If any of the below values do not match for the plugin being run, the handshake will fail. This means that the handshake acts as a type of versioning to instantly deprecate plugin apis that will no longer work.
More documentation on the HandshakeConfig here: https://pkg.go.dev/github.com/hashicorp/go-plugin#HandshakeConfig
Functions ¶
This section is empty.
Types ¶
type GRPCClient ¶
type GRPCClient struct {
// contains filtered or unexported fields
}
GRPCClient represents the implementation for a client that can talk to plugins. The client in this case is the main Tfvet process.
func (*GRPCClient) ExecuteRule ¶
func (m *GRPCClient) ExecuteRule(request *proto.ExecuteRuleRequest) (*proto.ExecuteRuleResponse, error)
ExecuteRule calls the corresponding ExecuteRule on the plugin through the GRPC client
func (*GRPCClient) GetRuleInfo ¶
func (m *GRPCClient) GetRuleInfo(request *proto.GetRuleInfoRequest) (*proto.GetRuleInfoResponse, error)
GetRuleInfo calls the corresponding GetRuleInfo method on the plugin through the GRPC client
type GRPCServer ¶
type GRPCServer struct { proto.UnimplementedTfvetRulePluginServer Impl RuleDefinition }
GRPCServer is the implementation that allows the plugin to respond to requests from the main process.
func (*GRPCServer) ExecuteRule ¶
func (m *GRPCServer) ExecuteRule(ctx context.Context, request *proto.ExecuteRuleRequest) (*proto.ExecuteRuleResponse, error)
ExecuteRule executes a single rule on a plugin
func (*GRPCServer) GetRuleInfo ¶
func (m *GRPCServer) GetRuleInfo(ctx context.Context, request *proto.GetRuleInfoRequest) (*proto.GetRuleInfoResponse, error)
GetRuleInfo gets information about the plugin
type RuleDefinition ¶
type RuleDefinition interface { ExecuteRule(request *proto.ExecuteRuleRequest) (*proto.ExecuteRuleResponse, error) GetRuleInfo(request *proto.GetRuleInfoRequest) (*proto.GetRuleInfoResponse, error) }
RuleDefinition is the interface in which both the plugin and the host has to implement
type TfvetRulePlugin ¶
type TfvetRulePlugin struct { plugin.Plugin Impl RuleDefinition }
TfvetRulePlugin is just a wrapper so we implement the correct go-plugin interface it allows us to serve/consume the plugin
func (*TfvetRulePlugin) GRPCClient ¶
func (p *TfvetRulePlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)
GRPCClient is the client implementation that allows our main process to send RPCs to plugins.
func (*TfvetRulePlugin) GRPCServer ¶
func (p *TfvetRulePlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
GRPCServer is the server implementation that allows our plugins to receive RPCs.