Documentation ¶
Overview ¶
Package tfmux provides a multiplexer that allows joining multiple Terraform provider servers into a single gRPC server.
This allows providers to use any framework or SDK built on github.com/hashicorp/terraform-plugin-go to build resources for their provider, and to join all the resources into a single logical provider even though they're implemented in different SDKs or frameworks.
Index ¶
- type SchemaServer
- func (s SchemaServer) ApplyResourceChange(ctx context.Context, req *tfprotov5.ApplyResourceChangeRequest) (*tfprotov5.ApplyResourceChangeResponse, error)
- func (s SchemaServer) ConfigureProvider(ctx context.Context, req *tfprotov5.ConfigureProviderRequest) (*tfprotov5.ConfigureProviderResponse, error)
- func (s SchemaServer) GetProviderSchema(ctx context.Context, req *tfprotov5.GetProviderSchemaRequest) (*tfprotov5.GetProviderSchemaResponse, error)
- func (s SchemaServer) ImportResourceState(ctx context.Context, req *tfprotov5.ImportResourceStateRequest) (*tfprotov5.ImportResourceStateResponse, error)
- func (s SchemaServer) PlanResourceChange(ctx context.Context, req *tfprotov5.PlanResourceChangeRequest) (*tfprotov5.PlanResourceChangeResponse, error)
- func (s SchemaServer) PrepareProviderConfig(ctx context.Context, req *tfprotov5.PrepareProviderConfigRequest) (*tfprotov5.PrepareProviderConfigResponse, error)
- func (s SchemaServer) ReadDataSource(ctx context.Context, req *tfprotov5.ReadDataSourceRequest) (*tfprotov5.ReadDataSourceResponse, error)
- func (s SchemaServer) ReadResource(ctx context.Context, req *tfprotov5.ReadResourceRequest) (*tfprotov5.ReadResourceResponse, error)
- func (s SchemaServer) StopProvider(ctx context.Context, req *tfprotov5.StopProviderRequest) (*tfprotov5.StopProviderResponse, error)
- func (s SchemaServer) UpgradeResourceState(ctx context.Context, req *tfprotov5.UpgradeResourceStateRequest) (*tfprotov5.UpgradeResourceStateResponse, error)
- func (s SchemaServer) ValidateDataSourceConfig(ctx context.Context, req *tfprotov5.ValidateDataSourceConfigRequest) (*tfprotov5.ValidateDataSourceConfigResponse, error)
- func (s SchemaServer) ValidateResourceTypeConfig(ctx context.Context, req *tfprotov5.ValidateResourceTypeConfigRequest) (*tfprotov5.ValidateResourceTypeConfigResponse, error)
- type SchemaServerFactory
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SchemaServer ¶
type SchemaServer struct {
// contains filtered or unexported fields
}
SchemaServer is a gRPC server implementation that stands in front of other gRPC servers, routing requests to them as if they were a single server. It should always be instantiated by calling SchemaServerFactory.Server().
func (SchemaServer) ApplyResourceChange ¶
func (s SchemaServer) ApplyResourceChange(ctx context.Context, req *tfprotov5.ApplyResourceChangeRequest) (*tfprotov5.ApplyResourceChangeResponse, error)
ApplyResourceChange calls the ApplyResourceChange method, passing `req`, on the provider that returned the resource specified by req.TypeName in its schema.
func (SchemaServer) ConfigureProvider ¶
func (s SchemaServer) ConfigureProvider(ctx context.Context, req *tfprotov5.ConfigureProviderRequest) (*tfprotov5.ConfigureProviderResponse, error)
ConfigureProvider calls each provider's ConfigureProvider method, one at a time, passing `req`. Any Diagnostic with severity error will abort the process and return immediately; non-Error severity Diagnostics will be combined and returned.
func (SchemaServer) GetProviderSchema ¶
func (s SchemaServer) GetProviderSchema(ctx context.Context, req *tfprotov5.GetProviderSchemaRequest) (*tfprotov5.GetProviderSchemaResponse, error)
GetProviderSchema merges the schemas returned by the tfprotov5.ProviderServers associated with SchemaServer into a single schema. Resources and data sources must be returned from only one server. Provider and ProviderMeta schemas must be identical between all servers.
func (SchemaServer) ImportResourceState ¶
func (s SchemaServer) ImportResourceState(ctx context.Context, req *tfprotov5.ImportResourceStateRequest) (*tfprotov5.ImportResourceStateResponse, error)
ImportResourceState calls the ImportResourceState method, passing `req`, on the provider that returned the resource specified by req.TypeName in its schema.
func (SchemaServer) PlanResourceChange ¶
func (s SchemaServer) PlanResourceChange(ctx context.Context, req *tfprotov5.PlanResourceChangeRequest) (*tfprotov5.PlanResourceChangeResponse, error)
PlanResourceChange calls the PlanResourceChange method, passing `req`, on the provider that returned the resource specified by req.TypeName in its schema.
func (SchemaServer) PrepareProviderConfig ¶
func (s SchemaServer) PrepareProviderConfig(ctx context.Context, req *tfprotov5.PrepareProviderConfigRequest) (*tfprotov5.PrepareProviderConfigResponse, error)
PrepareProviderConfig calls the PrepareProviderConfig method on each server in order, passing `req`. Only one may respond with a non-nil PreparedConfig or a non-empty Diagnostics.
func (SchemaServer) ReadDataSource ¶
func (s SchemaServer) ReadDataSource(ctx context.Context, req *tfprotov5.ReadDataSourceRequest) (*tfprotov5.ReadDataSourceResponse, error)
ReadDataSource calls the ReadDataSource method, passing `req`, on the provider that returned the data source specified by req.TypeName in its schema.
func (SchemaServer) ReadResource ¶
func (s SchemaServer) ReadResource(ctx context.Context, req *tfprotov5.ReadResourceRequest) (*tfprotov5.ReadResourceResponse, error)
ReadResource calls the ReadResource method, passing `req`, on the provider that returned the resource specified by req.TypeName in its schema.
func (SchemaServer) StopProvider ¶
func (s SchemaServer) StopProvider(ctx context.Context, req *tfprotov5.StopProviderRequest) (*tfprotov5.StopProviderResponse, error)
StopProvider calls the StopProvider function for each provider associated with the SchemaServer, one at a time. All Error fields will be joined together and returned, but will not prevent the rest of the providers' StopProvider methods from being called.
func (SchemaServer) UpgradeResourceState ¶
func (s SchemaServer) UpgradeResourceState(ctx context.Context, req *tfprotov5.UpgradeResourceStateRequest) (*tfprotov5.UpgradeResourceStateResponse, error)
UpgradeResourceState calls the UpgradeResourceState method, passing `req`, on the provider that returned the resource specified by req.TypeName in its schema.
func (SchemaServer) ValidateDataSourceConfig ¶
func (s SchemaServer) ValidateDataSourceConfig(ctx context.Context, req *tfprotov5.ValidateDataSourceConfigRequest) (*tfprotov5.ValidateDataSourceConfigResponse, error)
ValidateDataSourceConfig calls the ValidateDataSourceConfig method, passing `req`, on the provider that returned the data source specified by req.TypeName in its schema.
func (SchemaServer) ValidateResourceTypeConfig ¶
func (s SchemaServer) ValidateResourceTypeConfig(ctx context.Context, req *tfprotov5.ValidateResourceTypeConfigRequest) (*tfprotov5.ValidateResourceTypeConfigResponse, error)
ValidateResourceTypeConfig calls the ValidateResourceTypeConfig method, passing `req`, on the provider that returned the resource specified by req.TypeName in its schema.
type SchemaServerFactory ¶
type SchemaServerFactory struct {
// contains filtered or unexported fields
}
SchemaServerFactory is a generator for SchemaServers, which are Terraform gRPC servers that route requests to different gRPC provider implementations based on which gRPC provider implementation supports the resource the request is for.
SchemaServerFactory should always be instantiated by NewSchemaServerFactory.
func NewSchemaServerFactory ¶
func NewSchemaServerFactory(ctx context.Context, servers ...func() tfprotov5.ProviderServer) (SchemaServerFactory, error)
NewSchemaServerFactory returns a SchemaServerFactory that will route gRPC requests between the tfprotov5.ProviderServers specified. Each function specified is called, and the tfprotov5.ProviderServer has its GetProviderSchema method called. The schemas are used to determine which server handles each request, with requests for resources and data sources directed to the server that specified that data source or resource in its schema. Data sources and resources can only be specified in the schema of one ProviderServer.
Example (V2protocol) ¶
ctx := context.Background() // the ProviderServer from SDKv2 // usually this is the Provider function var sdkv2 func() tfprotov5.ProviderServer // the ProviderServer from the new protocol package var protocolServer func() tfprotov5.ProviderServer // requests will be routed to whichever server advertises support for // them in the GetSchema response. Only one server may advertise // support for any given resource, data source, or the provider or // provider_meta schemas. An error will be returned if more than one // server claims support. _, err := NewSchemaServerFactory(ctx, sdkv2, protocolServer) if err != nil { log.Println(err.Error()) os.Exit(1) } // use the result when instantiating the terraform-plugin-sdk.plugin.Serve /* plugin.Serve(&plugin.ServeOpts{ GRPCProviderFunc: plugin.GRPCProviderFunc(factory), }) */
Output:
func (SchemaServerFactory) Server ¶
func (s SchemaServerFactory) Server() SchemaServer
Server returns the SchemaServer that muxes between the tfprotov5.ProviderServers associated with the SchemaServerFactory.