Documentation ¶
Overview ¶
Package host2plugin contains a gRPC server (plugin) and client (host).
In the plugin system, this communication is the first thing that happens, and a plugin must use this package to provide a gRPC server. However, the detailed implementation is hidden in the tflint.RuleSet interface, and plugin developers usually don't need to be aware of gRPC server behavior.
When the host initializes a gRPC client, go-plugin starts a gRPC server on the plugin side as another process. This package acts as a wrapper for go-plugin. Separately, the Check function initializes a new gRPC client for plugin-to-host communication. See the plugin2host package for details.
Index ¶
- Constants
- func NewClient(opts *ClientOpts) *plugin.Client
- func Serve(opts *ServeOpts)
- type ClientOpts
- type GRPCClient
- func (c *GRPCClient) ApplyConfig(content *hclext.BodyContent, sources map[string][]byte) error
- func (c *GRPCClient) ApplyGlobalConfig(config *tflint.Config) error
- func (c *GRPCClient) Check(runner plugin2host.Server) error
- func (c *GRPCClient) ConfigSchema() (*hclext.BodySchema, error)
- func (c *GRPCClient) RuleNames() ([]string, error)
- func (c *GRPCClient) RuleSetName() (string, error)
- func (c *GRPCClient) RuleSetVersion() (string, error)
- func (c *GRPCClient) SDKVersion() (*version.Version, error)
- func (c *GRPCClient) VersionConstraints() (version.Constraints, error)
- type GRPCServer
- func (s *GRPCServer) ApplyConfig(ctx context.Context, req *proto.ApplyConfig_Request) (*proto.ApplyConfig_Response, error)
- func (s *GRPCServer) ApplyGlobalConfig(ctx context.Context, req *proto.ApplyGlobalConfig_Request) (*proto.ApplyGlobalConfig_Response, error)
- func (s *GRPCServer) Check(ctx context.Context, req *proto.Check_Request) (*proto.Check_Response, error)
- func (s *GRPCServer) GetConfigSchema(ctx context.Context, req *proto.GetConfigSchema_Request) (*proto.GetConfigSchema_Response, error)
- func (s *GRPCServer) GetName(ctx context.Context, req *proto.GetName_Request) (*proto.GetName_Response, error)
- func (s *GRPCServer) GetRuleNames(ctx context.Context, req *proto.GetRuleNames_Request) (*proto.GetRuleNames_Response, error)
- func (s *GRPCServer) GetSDKVersion(ctx context.Context, req *proto.GetSDKVersion_Request) (*proto.GetSDKVersion_Response, error)
- func (s *GRPCServer) GetVersion(ctx context.Context, req *proto.GetVersion_Request) (*proto.GetVersion_Response, error)
- func (s *GRPCServer) GetVersionConstraint(ctx context.Context, req *proto.GetVersionConstraint_Request) (*proto.GetVersionConstraint_Response, error)
- type RuleSetPlugin
- type ServeOpts
Constants ¶
const SDKVersion = "0.20.0"
SDKVersion is the SDK version.
Variables ¶
This section is empty.
Functions ¶
func NewClient ¶
func NewClient(opts *ClientOpts) *plugin.Client
NewClient is a wrapper of plugin.NewClient.
Types ¶
type ClientOpts ¶
ClientOpts is an option for initializing a Client.
type GRPCClient ¶
type GRPCClient struct {
// contains filtered or unexported fields
}
GRPCClient is a host-side implementation. Host can send requests through the client to plugin's gRPC server.
func (*GRPCClient) ApplyConfig ¶
func (c *GRPCClient) ApplyConfig(content *hclext.BodyContent, sources map[string][]byte) error
ApplyConfig applies the config to a plugin.
func (*GRPCClient) ApplyGlobalConfig ¶
func (c *GRPCClient) ApplyGlobalConfig(config *tflint.Config) error
ApplyGlobalConfig applies a common config to a plugin.
func (*GRPCClient) Check ¶
func (c *GRPCClient) Check(runner plugin2host.Server) error
Check calls its own plugin implementation with an gRPC client that can send requests to the host process.
func (*GRPCClient) ConfigSchema ¶
func (c *GRPCClient) ConfigSchema() (*hclext.BodySchema, error)
ConfigSchema fetches the config schema from a plugin.
func (*GRPCClient) RuleNames ¶
func (c *GRPCClient) RuleNames() ([]string, error)
RuleNames returns the list of rule names provided by a plugin.
func (*GRPCClient) RuleSetName ¶
func (c *GRPCClient) RuleSetName() (string, error)
RuleSetName returns the name of a plugin.
func (*GRPCClient) RuleSetVersion ¶
func (c *GRPCClient) RuleSetVersion() (string, error)
RuleSetVersion returns the version of a plugin.
func (*GRPCClient) SDKVersion ¶
func (c *GRPCClient) SDKVersion() (*version.Version, error)
SDKVersion returns the SDK version.
func (*GRPCClient) VersionConstraints ¶
func (c *GRPCClient) VersionConstraints() (version.Constraints, error)
VersionConstraints returns constraints of TFLint versions.
type GRPCServer ¶
type GRPCServer struct { proto.UnimplementedRuleSetServer // contains filtered or unexported fields }
GRPCServer is a plugin-side implementation. Plugin must implement a server that returns a response for a request from host. The behavior as gRPC server is implemented in the SDK, and the actual behavior is delegated to impl.
func (*GRPCServer) ApplyConfig ¶
func (s *GRPCServer) ApplyConfig(ctx context.Context, req *proto.ApplyConfig_Request) (*proto.ApplyConfig_Response, error)
ApplyConfig applies the plugin config retrieved from the host to the plugin.
func (*GRPCServer) ApplyGlobalConfig ¶
func (s *GRPCServer) ApplyGlobalConfig(ctx context.Context, req *proto.ApplyGlobalConfig_Request) (*proto.ApplyGlobalConfig_Response, error)
ApplyGlobalConfig applies a common config to the plugin.
func (*GRPCServer) Check ¶
func (s *GRPCServer) Check(ctx context.Context, req *proto.Check_Request) (*proto.Check_Response, error)
Check calls plugin rules with a gRPC client that can send requests to the host process.
func (*GRPCServer) GetConfigSchema ¶
func (s *GRPCServer) GetConfigSchema(ctx context.Context, req *proto.GetConfigSchema_Request) (*proto.GetConfigSchema_Response, error)
GetConfigSchema returns the config schema of the plugin.
func (*GRPCServer) GetName ¶
func (s *GRPCServer) GetName(ctx context.Context, req *proto.GetName_Request) (*proto.GetName_Response, error)
GetName returns the name of the plugin.
func (*GRPCServer) GetRuleNames ¶
func (s *GRPCServer) GetRuleNames(ctx context.Context, req *proto.GetRuleNames_Request) (*proto.GetRuleNames_Response, error)
GetRuleNames returns the list of rule names provided by the plugin.
func (*GRPCServer) GetSDKVersion ¶
func (s *GRPCServer) GetSDKVersion(ctx context.Context, req *proto.GetSDKVersion_Request) (*proto.GetSDKVersion_Response, error)
GetSDKVersion returns the SDK version.
func (*GRPCServer) GetVersion ¶
func (s *GRPCServer) GetVersion(ctx context.Context, req *proto.GetVersion_Request) (*proto.GetVersion_Response, error)
GetVersion returns the version of the plugin.
func (*GRPCServer) GetVersionConstraint ¶
func (s *GRPCServer) GetVersionConstraint(ctx context.Context, req *proto.GetVersionConstraint_Request) (*proto.GetVersionConstraint_Response, error)
GetVersionConstraint returns a constraint of TFLint versions.
type RuleSetPlugin ¶
type RuleSetPlugin struct { plugin.NetRPCUnsupportedPlugin // contains filtered or unexported fields }
RuleSetPlugin is a wrapper to satisfy the interface of go-plugin.
func (*RuleSetPlugin) GRPCClient ¶
func (*RuleSetPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)
GRPCClient returns an RPC client for the host.
func (*RuleSetPlugin) GRPCServer ¶
func (p *RuleSetPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
GRPCServer returns an gRPC server acting as a plugin.