plugin

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MPL-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The constants below are the names of the plugins that can be dispensed
	// from the plugin server.
	ProviderPluginName    = "provider"
	ProvisionerPluginName = "provisioner"

	// DefaultProtocolVersion is the protocol version assumed for legacy clients that don't specify
	// a particular version during their handshake. This is the version used when Terraform 0.10
	// and 0.11 launch plugins that were built with support for both versions 4 and 5, and must
	// stay unchanged at 4 until we intentionally build plugins that are not compatible with 0.10 and
	// 0.11.
	DefaultProtocolVersion = 4
)

Variables

View Source
var Handshake = plugin.HandshakeConfig{

	ProtocolVersion: DefaultProtocolVersion,

	MagicCookieKey:   "TF_PLUGIN_MAGIC_COOKIE",
	MagicCookieValue: "d602bf8f470bc67ca7faa0386276bbdd4330efaf76d1a219cb4d6991ca9872b2",
}

Handshake is the HandshakeConfig used to configure clients and servers.

View Source
var VersionedPlugins = map[int]plugin.PluginSet{
	5: {
		"provider":    &GRPCProviderPlugin{},
		"provisioner": &GRPCProvisionerPlugin{},
	},
	6: {
		"provider": &plugin6.GRPCProviderPlugin{},
	},
}

VersionedPlugins includes both protocol 5 and 6 because this is the function called in providerFactory (command/meta_providers.go) to set up the initial plugin client config.

Functions

func Serve

func Serve(opts *ServeOpts)

Serve serves a plugin. This function never returns and should be the final function called in the main function of the plugin.

Types

type GRPCProvider

type GRPCProvider struct {
	// PluginClient provides a reference to the plugin.Client which controls the plugin process.
	// This allows the GRPCProvider a way to shutdown the plugin process.
	PluginClient *plugin.Client

	// TestServer contains a grpc.Server to close when the GRPCProvider is being
	// used in an end to end test of a provider.
	TestServer *grpc.Server

	// SchemaCache stores the schema for this provider. This is used to properly
	// serialize the requests for schemas.  This is shared between instances
	// of the provider.
	SchemaCache providers.SchemaCache
	// contains filtered or unexported fields
}

GRPCProvider handles the client, or core side of the plugin rpc connection. The GRPCProvider methods are mostly a translation layer between the tofu providers types and the grpc proto types, directly converting between the two.

func (*GRPCProvider) CallFunction

func (*GRPCProvider) Close

func (p *GRPCProvider) Close(ctx context.Context) error

closing the grpc connection is final, and tofu will call it at the end of every phase.

func (*GRPCProvider) GetFunctions

func (p *GRPCProvider) GetFunctions(ctx context.Context) (resp providers.GetFunctionsResponse)

func (*GRPCProvider) GetProviderSchema

func (p *GRPCProvider) GetProviderSchema(ctx context.Context) (resp providers.GetProviderSchemaResponse)

func (*GRPCProvider) ListResource

ListResource enumerates the live instances of one managed resource type, buffering the whole stream. Use ListResourceStream instead when the result set may be large or when the caller wants to stop early.

func (*GRPCProvider) ListResourceStream

ListResourceStream enumerates the live instances of one managed resource type, calling emit once per result as the provider sends it. Returning false from emit ends the stream early and is not an error.

A provider that does not implement the list protocol at all, or that does not list this particular type, produces an error diagnostic saying so; it never panics and never reports a transport failure for that case.

func (*GRPCProvider) ReadDataSource

func (*GRPCProvider) ReadResource

func (*GRPCProvider) Stop

func (p *GRPCProvider) Stop(ctx context.Context) error

type GRPCProviderFunc

type GRPCProviderFunc func() proto.ProviderServer

type GRPCProviderPlugin

type GRPCProviderPlugin struct {
	plugin.Plugin
	GRPCProvider func() proto.ProviderServer
}

GRPCProviderPlugin implements plugin.GRPCPlugin for the go-plugin package.

func (*GRPCProviderPlugin) GRPCClient

func (p *GRPCProviderPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (any, error)

func (*GRPCProviderPlugin) GRPCServer

func (p *GRPCProviderPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

type GRPCProvisioner

type GRPCProvisioner struct {
	// PluginClient provides a reference to the plugin.Client which controls the plugin process.
	// This allows the GRPCProvider a way to shutdown the plugin process.
	PluginClient *plugin.Client
	// contains filtered or unexported fields
}

provisioners.Interface grpc implementation

func (*GRPCProvisioner) Close

func (p *GRPCProvisioner) Close() error

func (*GRPCProvisioner) GetSchema

func (p *GRPCProvisioner) GetSchema() (resp provisioners.GetSchemaResponse)

func (*GRPCProvisioner) Stop

func (p *GRPCProvisioner) Stop() error

type GRPCProvisionerFunc

type GRPCProvisionerFunc func() proto.ProvisionerServer

type GRPCProvisionerPlugin

type GRPCProvisionerPlugin struct {
	plugin.Plugin
	GRPCProvisioner func() proto.ProvisionerServer
}

GRPCProvisionerPlugin is the plugin.GRPCPlugin implementation.

func (*GRPCProvisionerPlugin) GRPCClient

func (p *GRPCProvisionerPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*GRPCProvisionerPlugin) GRPCServer

func (p *GRPCProvisionerPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

type ServeOpts

type ServeOpts struct {
	// Wrapped versions of the above plugins will automatically shimmed and
	// added to the GRPC functions when possible.
	GRPCProviderFunc    GRPCProviderFunc
	GRPCProvisionerFunc GRPCProvisionerFunc
}

ServeOpts are the configurations to serve a plugin.

type UIInput

type UIInput struct {
	Client *rpc.Client
}

UIInput is an implementation of tofu.UIInput that communicates over RPC.

func (*UIInput) Input

func (i *UIInput) Input(ctx context.Context, opts *tofu.InputOpts) (string, error)

type UIInputInputResponse

type UIInputInputResponse struct {
	Value string
	Error *plugin.BasicError
}

type UIInputServer

type UIInputServer struct {
	UIInput tofu.UIInput
}

UIInputServer is a net/rpc compatible structure for serving a UIInputServer. This should not be used directly.

func (*UIInputServer) Input

func (s *UIInputServer) Input(
	opts *tofu.InputOpts,
	reply *UIInputInputResponse) error

Directories

Path Synopsis
Package mock_tfplugin5 is a generated GoMock package.
Package mock_tfplugin5 is a generated GoMock package.

Jump to

Keyboard shortcuts

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