plugin

package
v0.13.6 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: MPL-2.0 Imports: 21 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{},
	},
}

Functions

func Client

func Client(m discovery.PluginMeta) *plugin.Client

Client returns a plugin client for the plugin described by the given metadata.

func ClientConfig

func ClientConfig(m discovery.PluginMeta) *plugin.ClientConfig

ClientConfig returns a configuration object that can be used to instantiate a client for the plugin described by the given metadata.

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 added in v0.12.0

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
	// 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 terraform provioders types and the grpc proto types, directly converting between the two.

func (*GRPCProvider) ApplyResourceChange added in v0.12.0

func (*GRPCProvider) Close added in v0.12.0

func (p *GRPCProvider) Close() error

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

func (*GRPCProvider) Configure added in v0.12.0

func (*GRPCProvider) GetSchema added in v0.12.0

func (p *GRPCProvider) GetSchema() (resp providers.GetSchemaResponse)

func (*GRPCProvider) ImportResourceState added in v0.12.0

func (*GRPCProvider) PlanResourceChange added in v0.12.0

func (*GRPCProvider) PrepareProviderConfig added in v0.12.0

func (*GRPCProvider) ReadDataSource added in v0.12.0

func (*GRPCProvider) ReadResource added in v0.12.0

func (*GRPCProvider) Stop added in v0.12.0

func (p *GRPCProvider) Stop() error

func (*GRPCProvider) UpgradeResourceState added in v0.12.0

func (*GRPCProvider) ValidateDataSourceConfig added in v0.12.0

func (*GRPCProvider) ValidateResourceTypeConfig added in v0.12.0

type GRPCProviderFunc added in v0.12.0

type GRPCProviderFunc func() proto.ProviderServer

type GRPCProviderPlugin added in v0.12.0

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

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

func (*GRPCProviderPlugin) GRPCClient added in v0.12.0

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

func (*GRPCProviderPlugin) GRPCServer added in v0.12.0

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

type GRPCProvisioner added in v0.12.0

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 added in v0.12.0

func (p *GRPCProvisioner) Close() error

func (*GRPCProvisioner) GetSchema added in v0.12.0

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

func (*GRPCProvisioner) ProvisionResource added in v0.12.0

func (*GRPCProvisioner) Stop added in v0.12.0

func (p *GRPCProvisioner) Stop() error

func (*GRPCProvisioner) ValidateProvisionerConfig added in v0.12.0

type GRPCProvisionerFunc added in v0.12.0

type GRPCProvisionerFunc func() proto.ProvisionerServer

type GRPCProvisionerPlugin added in v0.12.0

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

GRPCProvisionerPlugin is the plugin.GRPCPlugin implementation.

func (*GRPCProvisionerPlugin) GRPCClient added in v0.12.0

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

func (*GRPCProvisionerPlugin) GRPCServer added in v0.12.0

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

type ProviderFunc added in v0.7.0

type ProviderFunc func() terraform.ResourceProvider

type ProvisionerFunc added in v0.7.0

type ProvisionerFunc func() terraform.ResourceProvisioner

type ResourceProvider added in v0.7.0

type ResourceProvider struct {
	Broker *plugin.MuxBroker
	Client *rpc.Client
}

ResourceProvider is an implementation of terraform.ResourceProvider that communicates over RPC.

func (*ResourceProvider) Apply added in v0.7.0

func (*ResourceProvider) Close added in v0.7.0

func (p *ResourceProvider) Close() error

func (*ResourceProvider) Configure added in v0.7.0

func (*ResourceProvider) DataSources added in v0.7.0

func (p *ResourceProvider) DataSources() []terraform.DataSource

func (*ResourceProvider) Diff added in v0.7.0

func (*ResourceProvider) GetSchema added in v0.10.8

func (*ResourceProvider) ImportState added in v0.7.0

func (p *ResourceProvider) ImportState(
	info *terraform.InstanceInfo,
	id string) ([]*terraform.InstanceState, error)

func (*ResourceProvider) Input added in v0.7.0

func (*ResourceProvider) ReadDataApply added in v0.7.0

func (*ResourceProvider) ReadDataDiff added in v0.7.0

func (*ResourceProvider) Refresh added in v0.7.0

func (*ResourceProvider) Resources added in v0.7.0

func (p *ResourceProvider) Resources() []terraform.ResourceType

func (*ResourceProvider) Stop added in v0.8.0

func (p *ResourceProvider) Stop() error

func (*ResourceProvider) Validate added in v0.7.0

func (p *ResourceProvider) Validate(c *terraform.ResourceConfig) ([]string, []error)

func (*ResourceProvider) ValidateDataSource added in v0.7.0

func (p *ResourceProvider) ValidateDataSource(
	t string, c *terraform.ResourceConfig) ([]string, []error)

func (*ResourceProvider) ValidateResource added in v0.7.0

func (p *ResourceProvider) ValidateResource(
	t string, c *terraform.ResourceConfig) ([]string, []error)

type ResourceProviderApplyArgs added in v0.7.0

type ResourceProviderApplyArgs struct {
	Info  *terraform.InstanceInfo
	State *terraform.InstanceState
	Diff  *terraform.InstanceDiff
}

type ResourceProviderApplyResponse added in v0.7.0

type ResourceProviderApplyResponse struct {
	State *terraform.InstanceState
	Error *plugin.BasicError
}

type ResourceProviderConfigureResponse added in v0.7.0

type ResourceProviderConfigureResponse struct {
	Error *plugin.BasicError
}

type ResourceProviderDiffArgs added in v0.7.0

type ResourceProviderDiffArgs struct {
	Info   *terraform.InstanceInfo
	State  *terraform.InstanceState
	Config *terraform.ResourceConfig
}

type ResourceProviderDiffResponse added in v0.7.0

type ResourceProviderDiffResponse struct {
	Diff  *terraform.InstanceDiff
	Error *plugin.BasicError
}

type ResourceProviderGetSchemaArgs added in v0.10.8

type ResourceProviderGetSchemaArgs struct {
	Req *terraform.ProviderSchemaRequest
}

type ResourceProviderGetSchemaResponse added in v0.10.8

type ResourceProviderGetSchemaResponse struct {
	Schema *terraform.ProviderSchema
	Error  *plugin.BasicError
}

type ResourceProviderImportStateArgs added in v0.7.0

type ResourceProviderImportStateArgs struct {
	Info *terraform.InstanceInfo
	Id   string
}

type ResourceProviderImportStateResponse added in v0.7.0

type ResourceProviderImportStateResponse struct {
	State []*terraform.InstanceState
	Error *plugin.BasicError
}

type ResourceProviderInputArgs added in v0.7.0

type ResourceProviderInputArgs struct {
	InputId uint32
	Config  *terraform.ResourceConfig
}

type ResourceProviderInputResponse added in v0.7.0

type ResourceProviderInputResponse struct {
	Config *terraform.ResourceConfig
	Error  *plugin.BasicError
}

type ResourceProviderPlugin added in v0.7.0

type ResourceProviderPlugin struct {
	ResourceProvider func() terraform.ResourceProvider
}

ResourceProviderPlugin is the plugin.Plugin implementation.

func (*ResourceProviderPlugin) Client added in v0.7.0

func (p *ResourceProviderPlugin) Client(
	b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (*ResourceProviderPlugin) Server added in v0.7.0

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

type ResourceProviderReadDataApplyArgs added in v0.7.0

type ResourceProviderReadDataApplyArgs struct {
	Info *terraform.InstanceInfo
	Diff *terraform.InstanceDiff
}

type ResourceProviderReadDataApplyResponse added in v0.7.0

type ResourceProviderReadDataApplyResponse struct {
	State *terraform.InstanceState
	Error *plugin.BasicError
}

type ResourceProviderReadDataDiffArgs added in v0.7.0

type ResourceProviderReadDataDiffArgs struct {
	Info   *terraform.InstanceInfo
	Config *terraform.ResourceConfig
}

type ResourceProviderReadDataDiffResponse added in v0.7.0

type ResourceProviderReadDataDiffResponse struct {
	Diff  *terraform.InstanceDiff
	Error *plugin.BasicError
}

type ResourceProviderRefreshArgs added in v0.7.0

type ResourceProviderRefreshArgs struct {
	Info  *terraform.InstanceInfo
	State *terraform.InstanceState
}

type ResourceProviderRefreshResponse added in v0.7.0

type ResourceProviderRefreshResponse struct {
	State *terraform.InstanceState
	Error *plugin.BasicError
}

type ResourceProviderServer added in v0.7.0

type ResourceProviderServer struct {
	Broker   *plugin.MuxBroker
	Provider terraform.ResourceProvider
}

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

func (*ResourceProviderServer) Apply added in v0.7.0

func (*ResourceProviderServer) Configure added in v0.7.0

func (*ResourceProviderServer) DataSources added in v0.7.0

func (s *ResourceProviderServer) DataSources(
	nothing interface{},
	result *[]terraform.DataSource) error

func (*ResourceProviderServer) Diff added in v0.7.0

func (*ResourceProviderServer) GetSchema added in v0.10.8

func (*ResourceProviderServer) ImportState added in v0.7.0

func (*ResourceProviderServer) Input added in v0.7.0

func (*ResourceProviderServer) ReadDataApply added in v0.7.0

func (*ResourceProviderServer) ReadDataDiff added in v0.7.0

func (*ResourceProviderServer) Refresh added in v0.7.0

func (*ResourceProviderServer) Resources added in v0.7.0

func (s *ResourceProviderServer) Resources(
	nothing interface{},
	result *[]terraform.ResourceType) error

func (*ResourceProviderServer) Stop added in v0.8.0

func (s *ResourceProviderServer) Stop(
	_ interface{},
	reply *ResourceProviderStopResponse) error

func (*ResourceProviderServer) Validate added in v0.7.0

func (*ResourceProviderServer) ValidateDataSource added in v0.7.0

func (*ResourceProviderServer) ValidateResource added in v0.7.0

type ResourceProviderStopResponse added in v0.8.0

type ResourceProviderStopResponse struct {
	Error *plugin.BasicError
}

type ResourceProviderValidateArgs added in v0.7.0

type ResourceProviderValidateArgs struct {
	Config *terraform.ResourceConfig
}

type ResourceProviderValidateResourceArgs added in v0.7.0

type ResourceProviderValidateResourceArgs struct {
	Config *terraform.ResourceConfig
	Type   string
}

type ResourceProviderValidateResourceResponse added in v0.7.0

type ResourceProviderValidateResourceResponse struct {
	Warnings []string
	Errors   []*plugin.BasicError
}

type ResourceProviderValidateResponse added in v0.7.0

type ResourceProviderValidateResponse struct {
	Warnings []string
	Errors   []*plugin.BasicError
}

type ResourceProvisioner added in v0.7.0

type ResourceProvisioner struct {
	Broker *plugin.MuxBroker
	Client *rpc.Client
}

ResourceProvisioner is an implementation of terraform.ResourceProvisioner that communicates over RPC.

func (*ResourceProvisioner) Apply added in v0.7.0

func (*ResourceProvisioner) Close added in v0.7.0

func (p *ResourceProvisioner) Close() error

func (*ResourceProvisioner) GetConfigSchema added in v0.12.0

func (p *ResourceProvisioner) GetConfigSchema() (*configschema.Block, error)

func (*ResourceProvisioner) Stop added in v0.9.0

func (p *ResourceProvisioner) Stop() error

func (*ResourceProvisioner) Validate added in v0.7.0

func (p *ResourceProvisioner) Validate(c *terraform.ResourceConfig) ([]string, []error)

type ResourceProvisionerApplyArgs added in v0.7.0

type ResourceProvisionerApplyArgs struct {
	OutputId uint32
	State    *terraform.InstanceState
	Config   *terraform.ResourceConfig
}

type ResourceProvisionerApplyResponse added in v0.7.0

type ResourceProvisionerApplyResponse struct {
	Error *plugin.BasicError
}

type ResourceProvisionerPlugin added in v0.7.0

type ResourceProvisionerPlugin struct {
	ResourceProvisioner func() terraform.ResourceProvisioner
}

ResourceProvisionerPlugin is the plugin.Plugin implementation.

func (*ResourceProvisionerPlugin) Client added in v0.7.0

func (p *ResourceProvisionerPlugin) Client(
	b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (*ResourceProvisionerPlugin) Server added in v0.7.0

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

type ResourceProvisionerServer added in v0.7.0

type ResourceProvisionerServer struct {
	Broker      *plugin.MuxBroker
	Provisioner terraform.ResourceProvisioner
}

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

func (*ResourceProvisionerServer) Apply added in v0.7.0

func (*ResourceProvisionerServer) Stop added in v0.9.0

func (s *ResourceProvisionerServer) Stop(
	_ interface{},
	reply *ResourceProvisionerStopResponse) error

func (*ResourceProvisionerServer) Validate added in v0.7.0

type ResourceProvisionerStopResponse added in v0.9.0

type ResourceProvisionerStopResponse struct {
	Error *plugin.BasicError
}

type ResourceProvisionerValidateArgs added in v0.7.0

type ResourceProvisionerValidateArgs struct {
	Config *terraform.ResourceConfig
}

type ResourceProvisionerValidateResponse added in v0.7.0

type ResourceProvisionerValidateResponse struct {
	Warnings []string
	Errors   []*plugin.BasicError
}

type ServeOpts added in v0.3.0

type ServeOpts struct {
	ProviderFunc    ProviderFunc
	ProvisionerFunc ProvisionerFunc

	// 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 added in v0.7.0

type UIInput struct {
	Client *rpc.Client
}

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

func (*UIInput) Input added in v0.7.0

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

type UIInputInputResponse added in v0.7.0

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

type UIInputServer added in v0.7.0

type UIInputServer struct {
	UIInput terraform.UIInput
}

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

func (*UIInputServer) Input added in v0.7.0

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

type UIOutput added in v0.7.0

type UIOutput struct {
	Client *rpc.Client
}

UIOutput is an implementatin of terraform.UIOutput that communicates over RPC.

func (*UIOutput) Output added in v0.7.0

func (o *UIOutput) Output(v string)

type UIOutputServer added in v0.7.0

type UIOutputServer struct {
	UIOutput terraform.UIOutput
}

UIOutputServer is the RPC server for serving UIOutput.

func (*UIOutputServer) Output added in v0.7.0

func (s *UIOutputServer) Output(
	v string,
	reply *interface{}) 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