Documentation ¶
Overview ¶
Package tf6server implements a server implementation to run tfprotov6.ProviderServers as gRPC servers.
Providers will likely be calling tf6server.Serve from their main function to start the server so Terraform can connect to it.
Index ¶
- func New(serve tfprotov6.ProviderServer) tfplugin6.ProviderServer
- func Serve(name string, serverFactory func() tfprotov6.ProviderServer, opts ...ServeOpt) error
- type GRPCProviderPlugin
- func (p *GRPCProviderPlugin) Client(*plugin.MuxBroker, *rpc.Client) (interface{}, error)
- func (p *GRPCProviderPlugin) GRPCClient(context.Context, *plugin.GRPCBroker, *grpc.ClientConn) (interface{}, error)
- func (p *GRPCProviderPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
- func (p *GRPCProviderPlugin) Server(*plugin.MuxBroker) (interface{}, error)
- type ServeConfig
- type ServeOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(serve tfprotov6.ProviderServer) tfplugin6.ProviderServer
New converts a tfprotov6.ProviderServer into a server capable of handling Terraform protocol requests and issuing responses using the gRPC types.
func Serve ¶
func Serve(name string, serverFactory func() tfprotov6.ProviderServer, opts ...ServeOpt) error
Serve starts a tfprotov6.ProviderServer serving, ready for Terraform to connect to it. The name passed in should be the fully qualified name that users will enter in the source field of the required_providers block, like "registry.terraform.io/hashicorp/time".
Zero or more options to configure the server may also be passed. The default invocation is sufficient, but if the provider wants to run in debug mode or modify the logger that go-plugin is using, ServeOpts can be specified to support that.
Types ¶
type GRPCProviderPlugin ¶
type GRPCProviderPlugin struct {
GRPCProvider func() tfprotov6.ProviderServer
}
GRPCProviderPlugin is an implementation of the github.com/hashicorp/go-plugin#Plugin and github.com/hashicorp/go-plugin#GRPCPlugin interfaces, indicating how to serve tfprotov6.ProviderServers as gRPC plugins for go-plugin.
func (*GRPCProviderPlugin) Client ¶
func (p *GRPCProviderPlugin) Client(*plugin.MuxBroker, *rpc.Client) (interface{}, error)
Client always returns an error; we're only implementing the GRPCPlugin interface, not the Plugin interface.
func (*GRPCProviderPlugin) GRPCClient ¶
func (p *GRPCProviderPlugin) GRPCClient(context.Context, *plugin.GRPCBroker, *grpc.ClientConn) (interface{}, error)
GRPCClient always returns an error; we're only implementing the server half of the interface.
func (*GRPCProviderPlugin) GRPCServer ¶
func (p *GRPCProviderPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
GRPCServer registers the gRPC provider server with the gRPC server that go-plugin is standing up.
func (*GRPCProviderPlugin) Server ¶
func (p *GRPCProviderPlugin) Server(*plugin.MuxBroker) (interface{}, error)
Server always returns an error; we're only implementing the GRPCPlugin interface, not the Plugin interface.
type ServeConfig ¶
type ServeConfig struct {
// contains filtered or unexported fields
}
ServeConfig contains the configured options for how a provider should be served.
type ServeOpt ¶
type ServeOpt interface {
ApplyServeOpt(*ServeConfig) error
}
ServeOpt is an interface for defining options that can be passed to the Serve function. Each implementation modifies the ServeConfig being generated. A slice of ServeOpts then, cumulatively applied, render a full ServeConfig.
func WithDebug ¶
func WithDebug(ctx context.Context, config chan *plugin.ReattachConfig, closeCh chan struct{}) ServeOpt
WithDebug returns a ServeOpt that will set the server into debug mode, using the passed options to populate the go-plugin ServeTestConfig.
func WithGoPluginLogger ¶
func WithGoPluginLogger(logger hclog.Logger) ServeOpt
WithGoPluginLogger returns a ServeOpt that will set the logger that go-plugin should use to log messages.