Documentation ¶
Overview ¶
Package providerserver provides testsdk handling of serving a provider.
Index ¶
- func DynamicValueToValue(schema *tfprotov6.Schema, dynamicValue *tfprotov6.DynamicValue) (tftypes.Value, *tfprotov6.Diagnostic)
- func NewProtov5ProviderServer(p provider.Protov5Provider) func() (tfprotov5.ProviderServer, error)
- func NewProtov5ProviderServerWithError(p provider.Protov5Provider, err error) func() (tfprotov5.ProviderServer, error)
- func NewProviderServer(p provider.Provider) func() (tfprotov6.ProviderServer, error)
- func NewProviderServerWithError(p provider.Provider, err error) func() (tfprotov6.ProviderServer, error)
- func ProviderDataSource(p provider.Provider, typeName string) (datasource.DataSource, *tfprotov6.Diagnostic)
- func ProviderResource(p provider.Provider, typeName string) (resource.Resource, *tfprotov6.Diagnostic)
- func SchemaAttributeAtPath(schema *tfprotov6.Schema, path *tftypes.AttributePath) *tfprotov6.SchemaAttribute
- func ValuetoDynamicValue(schema *tfprotov6.Schema, value tftypes.Value) (*tfprotov6.DynamicValue, *tfprotov6.Diagnostic)
- type Protov5ProviderServer
- func (s Protov5ProviderServer) ApplyResourceChange(ctx context.Context, req *tfprotov5.ApplyResourceChangeRequest) (*tfprotov5.ApplyResourceChangeResponse, error)
- func (s Protov5ProviderServer) CallFunction(ctx context.Context, req *tfprotov5.CallFunctionRequest) (*tfprotov5.CallFunctionResponse, error)
- func (s Protov5ProviderServer) ConfigureProvider(ctx context.Context, req *tfprotov5.ConfigureProviderRequest) (*tfprotov5.ConfigureProviderResponse, error)
- func (s Protov5ProviderServer) GetFunctions(ctx context.Context, req *tfprotov5.GetFunctionsRequest) (*tfprotov5.GetFunctionsResponse, error)
- func (s Protov5ProviderServer) GetMetadata(ctx context.Context, request *tfprotov5.GetMetadataRequest) (*tfprotov5.GetMetadataResponse, error)
- func (s Protov5ProviderServer) GetProviderSchema(ctx context.Context, req *tfprotov5.GetProviderSchemaRequest) (*tfprotov5.GetProviderSchemaResponse, error)
- func (s Protov5ProviderServer) ImportResourceState(ctx context.Context, req *tfprotov5.ImportResourceStateRequest) (*tfprotov5.ImportResourceStateResponse, error)
- func (s Protov5ProviderServer) MoveResourceState(ctx context.Context, req *tfprotov5.MoveResourceStateRequest) (*tfprotov5.MoveResourceStateResponse, error)
- func (s Protov5ProviderServer) PlanResourceChange(ctx context.Context, req *tfprotov5.PlanResourceChangeRequest) (*tfprotov5.PlanResourceChangeResponse, error)
- func (s Protov5ProviderServer) PrepareProviderConfig(ctx context.Context, request *tfprotov5.PrepareProviderConfigRequest) (*tfprotov5.PrepareProviderConfigResponse, error)
- func (s Protov5ProviderServer) ReadDataSource(ctx context.Context, req *tfprotov5.ReadDataSourceRequest) (*tfprotov5.ReadDataSourceResponse, error)
- func (s Protov5ProviderServer) ReadResource(ctx context.Context, req *tfprotov5.ReadResourceRequest) (*tfprotov5.ReadResourceResponse, error)
- func (s Protov5ProviderServer) StopProvider(ctx context.Context, req *tfprotov5.StopProviderRequest) (*tfprotov5.StopProviderResponse, error)
- func (s Protov5ProviderServer) UpgradeResourceState(ctx context.Context, req *tfprotov5.UpgradeResourceStateRequest) (*tfprotov5.UpgradeResourceStateResponse, error)
- func (s Protov5ProviderServer) ValidateDataSourceConfig(ctx context.Context, request *tfprotov5.ValidateDataSourceConfigRequest) (*tfprotov5.ValidateDataSourceConfigResponse, error)
- func (s Protov5ProviderServer) ValidateResourceTypeConfig(ctx context.Context, request *tfprotov5.ValidateResourceTypeConfigRequest) (*tfprotov5.ValidateResourceTypeConfigResponse, error)
- type ProviderServer
- func (s ProviderServer) ApplyResourceChange(ctx context.Context, req *tfprotov6.ApplyResourceChangeRequest) (*tfprotov6.ApplyResourceChangeResponse, error)
- func (s ProviderServer) CallFunction(ctx context.Context, req *tfprotov6.CallFunctionRequest) (*tfprotov6.CallFunctionResponse, error)
- func (s ProviderServer) ConfigureProvider(ctx context.Context, req *tfprotov6.ConfigureProviderRequest) (*tfprotov6.ConfigureProviderResponse, error)
- func (s ProviderServer) GetFunctions(ctx context.Context, req *tfprotov6.GetFunctionsRequest) (*tfprotov6.GetFunctionsResponse, error)
- func (s ProviderServer) GetMetadata(ctx context.Context, request *tfprotov6.GetMetadataRequest) (*tfprotov6.GetMetadataResponse, error)
- func (s ProviderServer) GetProviderSchema(ctx context.Context, req *tfprotov6.GetProviderSchemaRequest) (*tfprotov6.GetProviderSchemaResponse, error)
- func (s ProviderServer) ImportResourceState(ctx context.Context, req *tfprotov6.ImportResourceStateRequest) (*tfprotov6.ImportResourceStateResponse, error)
- func (s ProviderServer) MoveResourceState(ctx context.Context, req *tfprotov6.MoveResourceStateRequest) (*tfprotov6.MoveResourceStateResponse, error)
- func (s ProviderServer) PlanResourceChange(ctx context.Context, req *tfprotov6.PlanResourceChangeRequest) (*tfprotov6.PlanResourceChangeResponse, error)
- func (s ProviderServer) ReadDataSource(ctx context.Context, req *tfprotov6.ReadDataSourceRequest) (*tfprotov6.ReadDataSourceResponse, error)
- func (s ProviderServer) ReadResource(ctx context.Context, req *tfprotov6.ReadResourceRequest) (*tfprotov6.ReadResourceResponse, error)
- func (s ProviderServer) StopProvider(ctx context.Context, req *tfprotov6.StopProviderRequest) (*tfprotov6.StopProviderResponse, error)
- func (s ProviderServer) UpgradeResourceState(ctx context.Context, req *tfprotov6.UpgradeResourceStateRequest) (*tfprotov6.UpgradeResourceStateResponse, error)
- func (s ProviderServer) ValidateDataResourceConfig(ctx context.Context, req *tfprotov6.ValidateDataResourceConfigRequest) (*tfprotov6.ValidateDataResourceConfigResponse, error)
- func (s ProviderServer) ValidateProviderConfig(ctx context.Context, req *tfprotov6.ValidateProviderConfigRequest) (*tfprotov6.ValidateProviderConfigResponse, error)
- func (s ProviderServer) ValidateResourceConfig(ctx context.Context, req *tfprotov6.ValidateResourceConfigRequest) (*tfprotov6.ValidateResourceConfigResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DynamicValueToValue ¶
func DynamicValueToValue(schema *tfprotov6.Schema, dynamicValue *tfprotov6.DynamicValue) (tftypes.Value, *tfprotov6.Diagnostic)
func NewProtov5ProviderServer ¶ added in v1.6.0
func NewProtov5ProviderServer(p provider.Protov5Provider) func() (tfprotov5.ProviderServer, error)
NewProtov5ProviderServer returns a protocol version 5 provider server which only implements GetProviderSchema, for consumption with ProtoV5ProviderFactories.
func NewProtov5ProviderServerWithError ¶ added in v1.6.0
func NewProtov5ProviderServerWithError(p provider.Protov5Provider, err error) func() (tfprotov5.ProviderServer, error)
NewProtov5ProviderServerWithError returns a protocol version 5 provider server, and an associated error for consumption with ProtoV5ProviderFactories.
func NewProviderServer ¶
func NewProviderServer(p provider.Provider) func() (tfprotov6.ProviderServer, error)
NewProviderServer returns a lightweight protocol version 6 provider server for consumption with ProtoV6ProviderFactories.
func NewProviderServerWithError ¶
func NewProviderServerWithError(p provider.Provider, err error) func() (tfprotov6.ProviderServer, error)
NewProviderServerWithError returns a lightweight protocol version 6 provider server and an associated error for consumption with ProtoV6ProviderFactories.
func ProviderDataSource ¶
func ProviderDataSource(p provider.Provider, typeName string) (datasource.DataSource, *tfprotov6.Diagnostic)
func ProviderResource ¶
func SchemaAttributeAtPath ¶
func SchemaAttributeAtPath(schema *tfprotov6.Schema, path *tftypes.AttributePath) *tfprotov6.SchemaAttribute
func ValuetoDynamicValue ¶
func ValuetoDynamicValue(schema *tfprotov6.Schema, value tftypes.Value) (*tfprotov6.DynamicValue, *tfprotov6.Diagnostic)
Types ¶
type Protov5ProviderServer ¶ added in v1.6.0
type Protov5ProviderServer struct {
Provider provider.Protov5Provider
}
Protov5ProviderServer is a version 5 provider server that only implements GetProviderSchema.
func (Protov5ProviderServer) ApplyResourceChange ¶ added in v1.6.0
func (s Protov5ProviderServer) ApplyResourceChange(ctx context.Context, req *tfprotov5.ApplyResourceChangeRequest) (*tfprotov5.ApplyResourceChangeResponse, error)
func (Protov5ProviderServer) CallFunction ¶ added in v1.8.0
func (s Protov5ProviderServer) CallFunction(ctx context.Context, req *tfprotov5.CallFunctionRequest) (*tfprotov5.CallFunctionResponse, error)
CallFunction implements tfprotov5.ProviderServer.
func (Protov5ProviderServer) ConfigureProvider ¶ added in v1.6.0
func (s Protov5ProviderServer) ConfigureProvider(ctx context.Context, req *tfprotov5.ConfigureProviderRequest) (*tfprotov5.ConfigureProviderResponse, error)
func (Protov5ProviderServer) GetFunctions ¶ added in v1.8.0
func (s Protov5ProviderServer) GetFunctions(ctx context.Context, req *tfprotov5.GetFunctionsRequest) (*tfprotov5.GetFunctionsResponse, error)
GetFunctions implements tfprotov5.ProviderServer.
func (Protov5ProviderServer) GetMetadata ¶ added in v1.6.0
func (s Protov5ProviderServer) GetMetadata(ctx context.Context, request *tfprotov5.GetMetadataRequest) (*tfprotov5.GetMetadataResponse, error)
func (Protov5ProviderServer) GetProviderSchema ¶ added in v1.6.0
func (s Protov5ProviderServer) GetProviderSchema(ctx context.Context, req *tfprotov5.GetProviderSchemaRequest) (*tfprotov5.GetProviderSchemaResponse, error)
func (Protov5ProviderServer) ImportResourceState ¶ added in v1.6.0
func (s Protov5ProviderServer) ImportResourceState(ctx context.Context, req *tfprotov5.ImportResourceStateRequest) (*tfprotov5.ImportResourceStateResponse, error)
func (Protov5ProviderServer) MoveResourceState ¶ added in v1.8.0
func (s Protov5ProviderServer) MoveResourceState(ctx context.Context, req *tfprotov5.MoveResourceStateRequest) (*tfprotov5.MoveResourceStateResponse, error)
func (Protov5ProviderServer) PlanResourceChange ¶ added in v1.6.0
func (s Protov5ProviderServer) PlanResourceChange(ctx context.Context, req *tfprotov5.PlanResourceChangeRequest) (*tfprotov5.PlanResourceChangeResponse, error)
func (Protov5ProviderServer) PrepareProviderConfig ¶ added in v1.6.0
func (s Protov5ProviderServer) PrepareProviderConfig(ctx context.Context, request *tfprotov5.PrepareProviderConfigRequest) (*tfprotov5.PrepareProviderConfigResponse, error)
func (Protov5ProviderServer) ReadDataSource ¶ added in v1.6.0
func (s Protov5ProviderServer) ReadDataSource(ctx context.Context, req *tfprotov5.ReadDataSourceRequest) (*tfprotov5.ReadDataSourceResponse, error)
func (Protov5ProviderServer) ReadResource ¶ added in v1.6.0
func (s Protov5ProviderServer) ReadResource(ctx context.Context, req *tfprotov5.ReadResourceRequest) (*tfprotov5.ReadResourceResponse, error)
func (Protov5ProviderServer) StopProvider ¶ added in v1.6.0
func (s Protov5ProviderServer) StopProvider(ctx context.Context, req *tfprotov5.StopProviderRequest) (*tfprotov5.StopProviderResponse, error)
func (Protov5ProviderServer) UpgradeResourceState ¶ added in v1.6.0
func (s Protov5ProviderServer) UpgradeResourceState(ctx context.Context, req *tfprotov5.UpgradeResourceStateRequest) (*tfprotov5.UpgradeResourceStateResponse, error)
func (Protov5ProviderServer) ValidateDataSourceConfig ¶ added in v1.6.0
func (s Protov5ProviderServer) ValidateDataSourceConfig(ctx context.Context, request *tfprotov5.ValidateDataSourceConfigRequest) (*tfprotov5.ValidateDataSourceConfigResponse, error)
func (Protov5ProviderServer) ValidateResourceTypeConfig ¶ added in v1.6.0
func (s Protov5ProviderServer) ValidateResourceTypeConfig(ctx context.Context, request *tfprotov5.ValidateResourceTypeConfigRequest) (*tfprotov5.ValidateResourceTypeConfigResponse, error)
type ProviderServer ¶
ProviderServer is a lightweight protocol version 6 provider server which is assumed to be well-behaved, e.g. does not return gRPC errors.
This implementation intends to reduce the heaviest parts of terraform-plugin-go based provider development:
- Converting *tfprotov6.DynamicValue to tftypes.Value using schema
- Splitting ApplyResourceChange into Create/Update/Delete calls
- Set PlanResourceChange null config values of Computed attributes to unknown
- Roundtrip UpgradeResourceState with equal schema version
By default, the following data is copied automatically:
- ApplyResourceChange (create): req.Config -> resp.NewState
- ApplyResourceChange (delete): req.PlannedState -> resp.NewState
- ApplyResourceChange (update): req.PlannedState -> resp.NewState
- PlanResourceChange: req.ProposedNewState -> resp.PlannedState
- ReadDataSource: req.Config -> resp.State
- ReadResource: req.CurrentState -> resp.NewState
func (ProviderServer) ApplyResourceChange ¶
func (s ProviderServer) ApplyResourceChange(ctx context.Context, req *tfprotov6.ApplyResourceChangeRequest) (*tfprotov6.ApplyResourceChangeResponse, error)
func (ProviderServer) CallFunction ¶ added in v1.8.0
func (s ProviderServer) CallFunction(ctx context.Context, req *tfprotov6.CallFunctionRequest) (*tfprotov6.CallFunctionResponse, error)
func (ProviderServer) ConfigureProvider ¶
func (s ProviderServer) ConfigureProvider(ctx context.Context, req *tfprotov6.ConfigureProviderRequest) (*tfprotov6.ConfigureProviderResponse, error)
func (ProviderServer) GetFunctions ¶ added in v1.8.0
func (s ProviderServer) GetFunctions(ctx context.Context, req *tfprotov6.GetFunctionsRequest) (*tfprotov6.GetFunctionsResponse, error)
func (ProviderServer) GetMetadata ¶ added in v1.6.0
func (s ProviderServer) GetMetadata(ctx context.Context, request *tfprotov6.GetMetadataRequest) (*tfprotov6.GetMetadataResponse, error)
func (ProviderServer) GetProviderSchema ¶
func (s ProviderServer) GetProviderSchema(ctx context.Context, req *tfprotov6.GetProviderSchemaRequest) (*tfprotov6.GetProviderSchemaResponse, error)
func (ProviderServer) ImportResourceState ¶
func (s ProviderServer) ImportResourceState(ctx context.Context, req *tfprotov6.ImportResourceStateRequest) (*tfprotov6.ImportResourceStateResponse, error)
func (ProviderServer) MoveResourceState ¶ added in v1.8.0
func (s ProviderServer) MoveResourceState(ctx context.Context, req *tfprotov6.MoveResourceStateRequest) (*tfprotov6.MoveResourceStateResponse, error)
func (ProviderServer) PlanResourceChange ¶
func (s ProviderServer) PlanResourceChange(ctx context.Context, req *tfprotov6.PlanResourceChangeRequest) (*tfprotov6.PlanResourceChangeResponse, error)
func (ProviderServer) ReadDataSource ¶
func (s ProviderServer) ReadDataSource(ctx context.Context, req *tfprotov6.ReadDataSourceRequest) (*tfprotov6.ReadDataSourceResponse, error)
func (ProviderServer) ReadResource ¶
func (s ProviderServer) ReadResource(ctx context.Context, req *tfprotov6.ReadResourceRequest) (*tfprotov6.ReadResourceResponse, error)
func (ProviderServer) StopProvider ¶
func (s ProviderServer) StopProvider(ctx context.Context, req *tfprotov6.StopProviderRequest) (*tfprotov6.StopProviderResponse, error)
func (ProviderServer) UpgradeResourceState ¶
func (s ProviderServer) UpgradeResourceState(ctx context.Context, req *tfprotov6.UpgradeResourceStateRequest) (*tfprotov6.UpgradeResourceStateResponse, error)
func (ProviderServer) ValidateDataResourceConfig ¶
func (s ProviderServer) ValidateDataResourceConfig(ctx context.Context, req *tfprotov6.ValidateDataResourceConfigRequest) (*tfprotov6.ValidateDataResourceConfigResponse, error)
func (ProviderServer) ValidateProviderConfig ¶
func (s ProviderServer) ValidateProviderConfig(ctx context.Context, req *tfprotov6.ValidateProviderConfigRequest) (*tfprotov6.ValidateProviderConfigResponse, error)
func (ProviderServer) ValidateResourceConfig ¶
func (s ProviderServer) ValidateResourceConfig(ctx context.Context, req *tfprotov6.ValidateResourceConfigRequest) (*tfprotov6.ValidateResourceConfigResponse, error)