github.com/terraform-linters/tflint-plugin-sdk@v0.22.0/plugin/internal/host2plugin/plugin.go (about) 1 package host2plugin 2 3 import ( 4 "context" 5 6 plugin "github.com/hashicorp/go-plugin" 7 "github.com/terraform-linters/tflint-plugin-sdk/plugin/internal/proto" 8 "github.com/terraform-linters/tflint-plugin-sdk/tflint" 9 "google.golang.org/grpc" 10 ) 11 12 // SDKVersion is the SDK version. 13 const SDKVersion = "0.22.0" 14 15 // handShakeConfig is used for UX. ProcotolVersion will be updated by incompatible changes. 16 var handshakeConfig = plugin.HandshakeConfig{ 17 ProtocolVersion: 11, 18 MagicCookieKey: "TFLINT_RULESET_PLUGIN", 19 MagicCookieValue: "5adSn1bX8nrDfgBqiAqqEkC6OE1h3iD8SqbMc5UUONx8x3xCF0KlPDsBRNDjoYDP", 20 } 21 22 // RuleSetPlugin is a wrapper to satisfy the interface of go-plugin. 23 type RuleSetPlugin struct { 24 plugin.NetRPCUnsupportedPlugin 25 26 impl tflint.RuleSet 27 } 28 29 var _ plugin.GRPCPlugin = &RuleSetPlugin{} 30 31 // GRPCServer returns an gRPC server acting as a plugin. 32 func (p *RuleSetPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error { 33 proto.RegisterRuleSetServer(s, &GRPCServer{ 34 impl: p.impl, 35 broker: broker, 36 }) 37 return nil 38 } 39 40 // GRPCClient returns an RPC client for the host. 41 func (*RuleSetPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) { 42 return &GRPCClient{ 43 client: proto.NewRuleSetClient(c), 44 broker: broker, 45 }, nil 46 }