Movatterモバイル変換


[0]ホーム

URL:


tf5server

package
v0.29.0Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License:MPL-2.0Imports:27Imported by:49

Details

Repository

github.com/hashicorp/terraform-plugin-go

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

Constants

This section is empty.

Variables

This section is empty.

Functions

funcNew

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

func (p *GRPCProviderPlugin) Client(*plugin.MuxBroker, *rpc.Client) (interface{},error)

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.

func (*GRPCProviderPlugin)Server

func (p *GRPCProviderPlugin) Server(*plugin.MuxBroker) (interface{},error)

Server always returns an error; we're only implementing the GRPCPlugininterface, not the Plugin interface.

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

func WithGoPluginLogger(loggerhclog.Logger)ServeOpt

WithGoPluginLogger returns a ServeOpt that will set the logger thatgo-plugin should use to log messages.

funcWithLogEnvVarNameadded inv0.5.0

func WithLogEnvVarName(namestring)ServeOpt

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.

funcWithLoggingSinkadded inv0.5.0

func WithLoggingSink(ttesting.T)ServeOpt

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.

funcWithManagedDebugadded 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.

funcWithManagedDebugEnvFilePathadded inv0.27.0

func WithManagedDebugEnvFilePath(pathstring)ServeOpt

WithManagedDebugEnvFilePath returns a ServeOpt that will set the output pathfor the managed debug process to write the reattach configuration into.

funcWithManagedDebugReattachConfigTimeoutadded inv0.6.0

func WithManagedDebugReattachConfigTimeout(timeouttime.Duration)ServeOpt

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.

funcWithManagedDebugStopSignalsadded inv0.6.0

func WithManagedDebugStopSignals(signals []os.Signal)ServeOpt

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.

funcWithoutLogLocationadded 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.

funcWithoutLogStderrOverrideadded 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.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp