tf5server
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package tf5server implements a server implementation to runtfprotov5.ProviderServers as gRPC servers.
Providers will likely be calling tf5server.Serve from their main function tostart the server so Terraform can connect to it.
Index¶
- func New(name string, serve tfprotov5.ProviderServer, opts ...ServeOpt) tfplugin5.ProviderServer
- func Serve(name string, serverFactory func() tfprotov5.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
- func WithDebug(ctx context.Context, config chan *plugin.ReattachConfig, closeCh chan struct{}) ServeOpt
- func WithGoPluginLogger(logger hclog.Logger) ServeOpt
- func WithLogEnvVarName(name string) ServeOpt
- func WithLoggingSink(t testing.T) ServeOpt
- func WithManagedDebug() ServeOpt
- func WithManagedDebugEnvFilePath(path string) ServeOpt
- func WithManagedDebugReattachConfigTimeout(timeout time.Duration) ServeOpt
- func WithManagedDebugStopSignals(signals []os.Signal) ServeOpt
- func WithoutLogLocation() ServeOpt
- func WithoutLogStderrOverride() ServeOpt
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcNew¶
func New(namestring, servetfprotov5.ProviderServer, opts ...ServeOpt)tfplugin5.ProviderServer
New converts a tfprotov5.ProviderServer into a server capable of handlingTerraform protocol requests and issuing responses using the gRPC types.
funcServe¶
func Serve(namestring, serverFactory func()tfprotov5.ProviderServer, opts ...ServeOpt)error
Serve starts a tfprotov5.ProviderServer serving, ready for Terraform toconnect to it. The name passed in should be the fully qualified name thatusers 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 defaultinvocation is sufficient, but if the provider wants to run in debug mode ormodify the logger that go-plugin is using, ServeOpts can be specified tosupport that.
Types¶
typeGRPCProviderPlugin¶
type GRPCProviderPlugin struct {GRPCProvider func()tfprotov5.ProviderServerOpts []ServeOptNamestring}GRPCProviderPlugin is an implementation of thegithub.com/hashicorp/go-plugin#Plugin andgithub.com/hashicorp/go-plugin#GRPCPlugin interfaces, indicating how toserve tfprotov5.ProviderServers as gRPC plugins for go-plugin.
func (*GRPCProviderPlugin)Client¶
Client always returns an error; we're only implementing the GRPCPlugininterface, 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 halfof 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 thatgo-plugin is standing up.
typeServeConfig¶
type ServeConfig struct {// contains filtered or unexported fields}ServeConfig contains the configured options for how a provider should beserved.
typeServeOpt¶
type ServeOpt interface {ApplyServeOpt(*ServeConfig)error}ServeOpt is an interface for defining options that can be passed to theServe function. Each implementation modifies the ServeConfig beinggenerated. A slice of ServeOpts then, cumulatively applied, render a fullServeConfig.
funcWithDebug¶
func WithDebug(ctxcontext.Context, config chan *plugin.ReattachConfig, closeCh chan struct{})ServeOpt
WithDebug returns a ServeOpt that will set the server into debug mode, usingthe passed options to populate the go-plugin ServeTestConfig.
This is an advanced ServeOpt that assumes the caller will fully manage thereattach configuration and server lifecycle. Refer to WithManagedDebug for aServeOpt that handles common use cases, such as implementing provider mainfunctions.
funcWithGoPluginLogger¶
WithGoPluginLogger returns a ServeOpt that will set the logger thatgo-plugin should use to log messages.
funcWithLogEnvVarName¶added inv0.5.0
WithLogEnvVarName sets the name of the provider for the purposes of thelogging environment variable that controls the provider's log level. It isthe part following TF_LOG_PROVIDER_ and defaults to the name part of theprovider's registry address, or disabled if it can't parse the provider'sregistry address. Name must only contain letters, numbers, and hyphens.
funcWithLoggingSink¶added inv0.5.0
WithLoggingSink returns a ServeOpt that will enable the logging sink, whichis used in test frameworks to control where terraform-plugin-log output iswritten and at what levels, mimicking Terraform's logging sink behaviors.
funcWithManagedDebug¶added inv0.6.0
func WithManagedDebug()ServeOpt
WithManagedDebug returns a ServeOpt that will start the server in debugmode, managing the reattach configuration handling and server lifecycle.Reattach configuration is output to stdout with human friendly instructions.By default, the server can be stopped with os.Interrupt (SIGINT; ctrl-c).
Refer to the optional WithManagedDebugStopSignals andWithManagedDebugReattachConfigTimeout ServeOpt for additional configuration.
The reattach configuration output of this handling is not protected bycompatibility guarantees. Use the WithDebug ServeOpt for advanced use cases.
funcWithManagedDebugEnvFilePath¶added inv0.27.0
WithManagedDebugEnvFilePath returns a ServeOpt that will set the output pathfor the managed debug process to write the reattach configuration into.
funcWithManagedDebugReattachConfigTimeout¶added inv0.6.0
WithManagedDebugReattachConfigTimeout returns a ServeOpt that will set the timeoutfor a debug managed process to start and return its reattach configuration.When not configured, 2 seconds is the default.
funcWithManagedDebugStopSignals¶added inv0.6.0
WithManagedDebugStopSignals returns a ServeOpt that will set the stop signals for adebug managed process (WithManagedDebug). When not configured, os.Interrupt(SIGINT; Ctrl-c) will stop the process.
funcWithoutLogLocation¶added inv0.5.0
func WithoutLogLocation()ServeOpt
WithoutLogLocation returns a ServeOpt that will exclude file names and linenumbers from log output for the terraform-plugin-log logs generated by theSDKs and provider.
funcWithoutLogStderrOverride¶added inv0.5.0
func WithoutLogStderrOverride()ServeOpt
WithoutLogStderrOverride returns a ServeOpt that will disable theterraform-plugin-log behavior of logging to the stderr that existed atstartup, not the stderr that exists when the logging statement is called.