tf5server

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2021 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package tf5server implements a server implementation to run tfprotov5.ProviderServers as gRPC servers.

Providers will likely be calling tf5server.Serve from their main function to start the server so Terraform can connect to it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New converts a tfprotov5.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() tfprotov5.ProviderServer, opts ...ServeOpt) error

Serve starts a tfprotov5.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() tfprotov5.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 tfprotov5.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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL