fwserver

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MPL-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package fwserver contains the framework provider server implementation. This package should only ever contain framework-native types, while specific protocol version compatible implementations, such as proto6server, are implemented on top of this abstraction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttributeModifyPlan added in v0.9.0

AttributeModifyPlan runs all AttributePlanModifiers

TODO: Clean up this abstraction back into an internal Attribute type method. The extra Attribute parameter is a carry-over of creating the proto6server package from the tfsdk package and not wanting to export the method. Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/365

func AttributePlanModifyBool added in v0.17.0

AttributePlanModifyBool performs all types.Bool plan modification.

func AttributePlanModifyDynamic added in v1.7.0

AttributePlanModifyDynamic performs all types.Dynamic plan modification.

func AttributePlanModifyFloat64 added in v0.17.0

AttributePlanModifyFloat64 performs all types.Float64 plan modification.

func AttributePlanModifyInt64 added in v0.17.0

AttributePlanModifyInt64 performs all types.Int64 plan modification.

func AttributePlanModifyList added in v0.17.0

AttributePlanModifyList performs all types.List plan modification.

func AttributePlanModifyMap added in v0.17.0

AttributePlanModifyMap performs all types.Map plan modification.

func AttributePlanModifyNumber added in v0.17.0

AttributePlanModifyNumber performs all types.Number plan modification.

func AttributePlanModifyObject added in v0.17.0

AttributePlanModifyObject performs all types.Object plan modification.

func AttributePlanModifySet added in v0.17.0

AttributePlanModifySet performs all types.Set plan modification.

func AttributePlanModifyString added in v0.17.0

AttributePlanModifyString performs all types.String plan modification.

func AttributeValidate added in v0.9.0

AttributeValidate performs all Attribute validation.

TODO: Clean up this abstraction back into an internal Attribute type method. The extra Attribute parameter is a carry-over of creating the proto6server package from the tfsdk package and not wanting to export the method. Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/365

func AttributeValidateBool added in v0.17.0

AttributeValidateBool performs all types.Bool validation.

func AttributeValidateDynamic added in v1.7.0

AttributeValidateDynamic performs all types.Dynamic validation.

func AttributeValidateFloat64 added in v0.17.0

AttributeValidateFloat64 performs all types.Float64 validation.

func AttributeValidateInt64 added in v0.17.0

AttributeValidateInt64 performs all types.Int64 validation.

func AttributeValidateList added in v0.17.0

AttributeValidateList performs all types.List validation.

func AttributeValidateMap added in v0.17.0

AttributeValidateMap performs all types.Map validation.

func AttributeValidateNestedAttributes added in v0.9.0

func AttributeValidateNestedAttributes(ctx context.Context, a fwschema.Attribute, req ValidateAttributeRequest, resp *ValidateAttributeResponse)

AttributeValidateNestedAttributes performs all nested Attributes validation.

TODO: Clean up this abstraction back into an internal Attribute type method. The extra Attribute parameter is a carry-over of creating the proto6server package from the tfsdk package and not wanting to export the method. Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/365

func AttributeValidateNumber added in v0.17.0

AttributeValidateNumber performs all types.Number validation.

func AttributeValidateObject added in v0.17.0

AttributeValidateObject performs all types.Object validation.

func AttributeValidateSet added in v0.17.0

AttributeValidateSet performs all types.Set validation.

func AttributeValidateString added in v0.17.0

AttributeValidateString performs all types.String validation.

func BlockModifyPlan added in v0.9.0

BlockModifyPlan performs all Block plan modification.

TODO: Clean up this abstraction back into an internal Block type method. The extra Block parameter is a carry-over of creating the proto6server package from the tfsdk package and not wanting to export the method. Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/365

func BlockPlanModifyList added in v0.17.0

BlockPlanModifyList performs all types.List plan modification.

func BlockPlanModifyObject added in v0.17.0

BlockPlanModifyObject performs all types.Object plan modification.

func BlockPlanModifySet added in v0.17.0

BlockPlanModifySet performs all types.Set plan modification.

func BlockValidate added in v0.9.0

BlockValidate performs all Block validation.

TODO: Clean up this abstraction back into an internal Block type method. The extra Block parameter is a carry-over of creating the proto6server package from the tfsdk package and not wanting to export the method. Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/365

func BlockValidateList added in v0.17.0

BlockValidateList performs all types.List validation.

func BlockValidateObject added in v0.17.0

BlockValidateObject performs all types.Object validation.

func BlockValidateSet added in v0.17.0

BlockValidateSet performs all types.Set validation.

func MarkComputedNilsAsUnknown added in v0.9.0

func MarkComputedNilsAsUnknown(ctx context.Context, config tftypes.Value, resourceSchema fwschema.Schema) func(*tftypes.AttributePath, tftypes.Value) (tftypes.Value, error)

func NestedAttributeObjectPlanModify added in v0.17.0

func NestedAttributeObjectPlanModify(ctx context.Context, o fwschema.NestedAttributeObject, req planmodifier.ObjectRequest, resp *ModifyAttributePlanResponse)

func NestedAttributeObjectValidate added in v0.17.0

func NestedAttributeObjectValidate(ctx context.Context, o fwschema.NestedAttributeObject, req ValidateAttributeRequest, resp *ValidateAttributeResponse)

func NestedBlockObjectPlanModify added in v0.17.0

func NestedBlockObjectPlanModify(ctx context.Context, o fwschema.NestedBlockObject, req planmodifier.ObjectRequest, resp *ModifyAttributePlanResponse)

func NestedBlockObjectValidate added in v0.17.0

func NormaliseRequiresReplace added in v0.9.0

func NormaliseRequiresReplace(ctx context.Context, rs path.Paths) path.Paths

NormaliseRequiresReplace sorts and deduplicates the slice of AttributePaths used in the RequiresReplace response field. Sorting is lexical based on the string representation of each AttributePath.

func SchemaModifyPlan added in v0.9.0

SchemaModifyPlan runs all AttributePlanModifiers in all schema attributes and blocks.

TODO: Clean up this abstraction back into an internal Schema type method. The extra Schema parameter is a carry-over of creating the proto6server package from the tfsdk package and not wanting to export the method. Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/365

func SchemaSemanticEquality added in v1.3.0

func SchemaSemanticEquality(ctx context.Context, req SchemaSemanticEqualityRequest, resp *SchemaSemanticEqualityResponse)

SchemaSemanticEquality runs semantic equality logic for all schema attributes and blocks.

MAINTAINER NOTE: Since semantic equality is purely value based, where attributes and blocks cannot currently introduce semantic equality logic based on those schema concepts, this logic immediately delegates to value based handling. On the off chance that the framework is enhanced with attribute and block level semantic equality support (not recommended since value types should really be the correct provider developer abstraction, rather than potentially causing confusing or duplicated provider logic), this logic will need to be redesigned similar to the plan modification and validation logic which walks the schema. That schema walk may interfere with the value based recursion for collection and structural types, so additional design may be necessary so that provider developer data handling intentions are kept based on both the value based logic and schema based logic.

func SchemaValidate added in v0.9.0

SchemaValidate performs all Attribute and Block validation.

TODO: Clean up this abstraction back into an internal Schema type method. The extra Schema parameter is a carry-over of creating the proto6server package from the tfsdk package and not wanting to export the method. Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/365

Types

type ApplyResourceChangeRequest added in v0.9.0

type ApplyResourceChangeRequest struct {
	Config         *tfsdk.Config
	PlannedPrivate *privatestate.Data
	PlannedState   *tfsdk.Plan
	PriorState     *tfsdk.State
	ProviderMeta   *tfsdk.Config
	ResourceSchema fwschema.Schema
	Resource       resource.Resource
}

ApplyResourceChangeRequest is the framework server request for the ApplyResourceChange RPC.

type ApplyResourceChangeResponse added in v0.9.0

type ApplyResourceChangeResponse struct {
	Diagnostics diag.Diagnostics
	NewState    *tfsdk.State
	Private     *privatestate.Data
}

ApplyResourceChangeResponse is the framework server response for the ApplyResourceChange RPC.

type CallFunctionRequest added in v1.5.0

type CallFunctionRequest struct {
	Arguments          function.ArgumentsData
	Function           function.Function
	FunctionDefinition function.Definition
}

CallFunctionRequest is the framework server request for the CallFunction RPC.

type CallFunctionResponse added in v1.5.0

type CallFunctionResponse struct {
	Error  *function.FuncError
	Result function.ResultData
}

CallFunctionResponse is the framework server response for the CallFunction RPC.

type CreateResourceRequest added in v0.9.0

type CreateResourceRequest struct {
	Config         *tfsdk.Config
	PlannedPrivate *privatestate.Data
	PlannedState   *tfsdk.Plan
	ProviderMeta   *tfsdk.Config
	ResourceSchema fwschema.Schema
	Resource       resource.Resource
}

CreateResourceRequest is the framework server request for a create request with the ApplyResourceChange RPC.

type CreateResourceResponse added in v0.9.0

type CreateResourceResponse struct {
	Diagnostics diag.Diagnostics
	NewState    *tfsdk.State
	Private     *privatestate.Data
}

CreateResourceResponse is the framework server response for a create request with the ApplyResourceChange RPC.

type DataSourceMetadata added in v1.4.0

type DataSourceMetadata struct {
	// TypeName is the name of the data resource.
	TypeName string
}

DataSourceMetadata is the framework server equivalent of the tfprotov5.DataSourceMetadata and tfprotov6.DataSourceMetadata types.

type DeleteResourceRequest added in v0.9.0

type DeleteResourceRequest struct {
	PlannedPrivate *privatestate.Data
	PriorState     *tfsdk.State
	ProviderMeta   *tfsdk.Config
	ResourceSchema fwschema.Schema
	Resource       resource.Resource
}

DeleteResourceRequest is the framework server request for a delete request with the ApplyResourceChange RPC.

type DeleteResourceResponse added in v0.9.0

type DeleteResourceResponse struct {
	Diagnostics diag.Diagnostics
	NewState    *tfsdk.State
	Private     *privatestate.Data
}

DeleteResourceResponse is the framework server response for a delete request with the ApplyResourceChange RPC.

type FunctionMetadata added in v1.5.0

type FunctionMetadata struct {
	// Name is the name of the function.
	Name string
}

FunctionMetadata is the framework server equivalent of the tfprotov5.FunctionMetadata and tfprotov6.FunctionMetadata types.

type GetFunctionsRequest added in v1.5.0

type GetFunctionsRequest struct{}

GetFunctionsRequest is the framework server request for the GetFunctions RPC.

type GetFunctionsResponse added in v1.5.0

type GetFunctionsResponse struct {
	FunctionDefinitions map[string]function.Definition
	Diagnostics         diag.Diagnostics
}

GetFunctionsResponse is the framework server response for the GetFunctions RPC.

type GetMetadataRequest added in v1.4.0

type GetMetadataRequest struct{}

GetMetadataRequest is the framework server request for the GetMetadata RPC.

type GetMetadataResponse added in v1.4.0

type GetMetadataResponse struct {
	DataSources        []DataSourceMetadata
	Diagnostics        diag.Diagnostics
	Functions          []FunctionMetadata
	Resources          []ResourceMetadata
	ServerCapabilities *ServerCapabilities
}

GetMetadataResponse is the framework server response for the GetMetadata RPC.

type GetProviderSchemaRequest

type GetProviderSchemaRequest struct{}

GetProviderSchemaRequest is the framework server request for the GetProviderSchema RPC.

type GetProviderSchemaResponse

type GetProviderSchemaResponse struct {
	ServerCapabilities  *ServerCapabilities
	Provider            fwschema.Schema
	ProviderMeta        fwschema.Schema
	ResourceSchemas     map[string]fwschema.Schema
	DataSourceSchemas   map[string]fwschema.Schema
	FunctionDefinitions map[string]function.Definition
	Diagnostics         diag.Diagnostics
}

GetProviderSchemaResponse is the framework server response for the GetProviderSchema RPC.

type ImportResourceStateRequest added in v0.9.0

type ImportResourceStateRequest struct {
	ID       string
	Resource resource.Resource

	// EmptyState is an empty State for the resource schema. This is used to
	// initialize the ImportedResource State of the ImportResourceStateResponse
	// and allow the framework server to verify that the provider updated the
	// state after the provider defined logic.
	EmptyState tfsdk.State

	// TypeName is the resource type name, which is necessary for populating
	// the ImportedResource TypeName of the ImportResourceStateResponse.
	TypeName string
}

ImportResourceStateRequest is the framework server request for the ImportResourceState RPC.

type ImportResourceStateResponse added in v0.9.0

type ImportResourceStateResponse struct {
	Diagnostics       diag.Diagnostics
	ImportedResources []ImportedResource
}

ImportResourceStateResponse is the framework server response for the ImportResourceState RPC.

type ImportedResource added in v0.9.0

type ImportedResource struct {
	Private  *privatestate.Data
	State    tfsdk.State
	TypeName string
}

ImportedResource represents a resource that was imported.

type ModifyAttributePlanRequest added in v1.0.0

type ModifyAttributePlanRequest struct {
	// AttributePath is the path of the attribute. Use this path for any
	// response diagnostics.
	AttributePath path.Path

	// AttributePathExpression is the expression matching the exact path of the
	// attribute.
	AttributePathExpression path.Expression

	// Config is the configuration the user supplied for the resource.
	Config tfsdk.Config

	// State is the current state of the resource.
	State tfsdk.State

	// Plan is the planned new state for the resource.
	Plan tfsdk.Plan

	// AttributeConfig is the configuration the user supplied for the attribute.
	AttributeConfig attr.Value

	// AttributeState is the current state of the attribute.
	AttributeState attr.Value

	// AttributePlan is the planned new state for the attribute.
	AttributePlan attr.Value

	// ProviderMeta is metadata from the provider_meta block of the module.
	ProviderMeta tfsdk.Config

	// Private is provider-defined resource private state data which was previously
	// stored with the resource state. This data is opaque to Terraform and does
	// not affect plan output. Any existing data is copied to
	// ModifyAttributePlanResponse.Private to prevent accidental private state data loss.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	//
	// Use the GetKey method to read data. Use the SetKey method on
	// ModifyAttributePlanResponse.Private to update or remove a value.
	Private *privatestate.ProviderData
}

ModifyAttributePlanRequest represents a request for the provider to modify an attribute value, or mark it as requiring replacement, at plan time. An instance of this request struct is supplied as an argument to the Modify function of an attribute's plan modifier(s).

type ModifyAttributePlanResponse added in v0.12.0

type ModifyAttributePlanResponse struct {
	AttributePlan   attr.Value
	Diagnostics     diag.Diagnostics
	RequiresReplace path.Paths
	Private         *privatestate.ProviderData
}

type ModifySchemaPlanRequest added in v0.9.0

type ModifySchemaPlanRequest struct {
	// Config is the configuration the user supplied for the resource.
	Config tfsdk.Config

	// State is the current state of the resource.
	State tfsdk.State

	// Plan is the planned new state for the resource.
	Plan tfsdk.Plan

	// ProviderMeta is metadata from the provider_meta block of the module.
	ProviderMeta tfsdk.Config

	// Private is provider private state data.
	Private *privatestate.ProviderData
}

ModifySchemaPlanRequest represents a request for a schema to run all attribute plan modification functions.

type ModifySchemaPlanResponse added in v0.9.0

type ModifySchemaPlanResponse struct {
	// Plan is the planned new state for the resource.
	Plan tfsdk.Plan

	// RequiresReplace is a list of attribute paths that require the
	// resource to be replaced. They should point to the specific field
	// that changed that requires the resource to be destroyed and
	// recreated.
	RequiresReplace path.Paths

	// Private is provider private state data following potential modifications.
	Private *privatestate.ProviderData

	// Diagnostics report errors or warnings related to running all attribute
	// plan modifiers. Returning an empty slice indicates a successful
	// plan modification with no warnings or errors generated.
	Diagnostics diag.Diagnostics
}

ModifySchemaPlanResponse represents a response to a ModifySchemaPlanRequest.

type MoveResourceStateRequest added in v1.6.0

type MoveResourceStateRequest struct {
	// SourcePrivate is the private state of the source resource as given by
	// Terraform across the protocol.
	SourcePrivate *privatestate.Data

	// SourceProviderAddress is the address of the source provider as given by
	// Terraform across the protocol.
	SourceProviderAddress string

	// SourceSchemaVersion is the version of the source resource schema as given
	// by Terraform across the protocol.
	SourceSchemaVersion int64

	// SourceRawState is the raw state of the source resource as given by
	// Terraform across the protocol.
	//
	// Using the tfprotov6 type here was a pragmatic effort decision around when
	// the framework introduced compatibility promises. This type was chosen as
	// it was readily available and trivial to convert between tfprotov5.
	//
	// Using a terraform-plugin-go type is not ideal for the framework as almost
	// all terraform-plugin-go types have framework abstractions, but if there
	// is ever a time where it makes sense to re-evaluate this decision, such as
	// a major version bump, it could be changed then.
	// Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/340
	SourceRawState *tfprotov6.RawState

	// SourceTypeName is the type name of the source resource as given by
	// Terraform across the protocol.
	SourceTypeName string

	// TargetResource is the provider-defined resource implementation as
	// determined by the framework looking up the resource name from the
	// provider.Provider implementation Resources method defined by the
	// provider developer.
	TargetResource resource.Resource

	// TargetResourceSchema is the evaluated schema definition of the target
	// resource as determined by the framework calling the resource.Resource
	// implementation Schema method defined by the provider developer.
	TargetResourceSchema fwschema.Schema

	// TargetTypeName is the type name of the target resource as given by
	// Terraform across the protocol.
	TargetTypeName string
}

MoveResourceStateRequest is the framework server request for the MoveResourceState RPC.

type MoveResourceStateResponse added in v1.6.0

type MoveResourceStateResponse struct {
	Diagnostics   diag.Diagnostics
	TargetPrivate *privatestate.Data
	TargetState   *tfsdk.State
}

MoveResourceStateResponse is the framework server response for the MoveResourceState RPC.

type PlanResourceChangeRequest added in v0.9.0

type PlanResourceChangeRequest struct {
	Config           *tfsdk.Config
	PriorPrivate     *privatestate.Data
	PriorState       *tfsdk.State
	ProposedNewState *tfsdk.Plan
	ProviderMeta     *tfsdk.Config
	ResourceSchema   fwschema.Schema
	Resource         resource.Resource
}

PlanResourceChangeRequest is the framework server request for the PlanResourceChange RPC.

type PlanResourceChangeResponse added in v0.9.0

type PlanResourceChangeResponse struct {
	Diagnostics     diag.Diagnostics
	PlannedPrivate  *privatestate.Data
	PlannedState    *tfsdk.State
	RequiresReplace path.Paths
}

PlanResourceChangeResponse is the framework server response for the PlanResourceChange RPC.

type ReadDataSourceRequest added in v0.9.0

type ReadDataSourceRequest struct {
	Config           *tfsdk.Config
	DataSourceSchema fwschema.Schema
	DataSource       datasource.DataSource
	ProviderMeta     *tfsdk.Config
}

ReadDataSourceRequest is the framework server request for the ReadDataSource RPC.

type ReadDataSourceResponse added in v0.9.0

type ReadDataSourceResponse struct {
	Diagnostics diag.Diagnostics
	State       *tfsdk.State
}

ReadDataSourceResponse is the framework server response for the ReadDataSource RPC.

type ReadResourceRequest added in v0.9.0

type ReadResourceRequest struct {
	CurrentState *tfsdk.State
	Resource     resource.Resource
	Private      *privatestate.Data
	ProviderMeta *tfsdk.Config
}

ReadResourceRequest is the framework server request for the ReadResource RPC.

type ReadResourceResponse added in v0.9.0

type ReadResourceResponse struct {
	Diagnostics diag.Diagnostics
	NewState    *tfsdk.State
	Private     *privatestate.Data
}

ReadResourceResponse is the framework server response for the ReadResource RPC.

type ResourceMetadata added in v1.4.0

type ResourceMetadata struct {
	// TypeName is the name of the managed resource.
	TypeName string
}

ResourceMetadata is the framework server equivalent of the tfprotov5.ResourceMetadata and tfprotov6.ResourceMetadata types.

type SchemaSemanticEqualityRequest added in v1.3.0

type SchemaSemanticEqualityRequest struct {
	// PriorData is the prior schema-based data.
	PriorData fwschemadata.Data

	// ProposedNewData is the proposed new schema-based data. The response
	// NewData contains the results of any modifications.
	ProposedNewData fwschemadata.Data
}

SchemaSemanticEqualityRequest represents a request for a schema to run all semantic equality logic.

type SchemaSemanticEqualityResponse added in v1.3.0

type SchemaSemanticEqualityResponse struct {
	// NewData is the new schema-based data after any modifications.
	NewData fwschemadata.Data

	// Diagnostics report errors or warnings related to running all attribute
	// plan modifiers. Returning an empty slice indicates a successful
	// plan modification with no warnings or errors generated.
	Diagnostics diag.Diagnostics
}

SchemaSemanticEqualityResponse represents a response to a SchemaSemanticEqualityRequest.

type Server

type Server struct {
	Provider provider.Provider

	// DataSourceConfigureData is the
	// [provider.ConfigureResponse.DataSourceData] field value which is passed
	// to [datasource.ConfigureRequest.ProviderData].
	DataSourceConfigureData any

	// ResourceConfigureData is the
	// [provider.ConfigureResponse.ResourceData] field value which is passed
	// to [resource.ConfigureRequest.ProviderData].
	ResourceConfigureData any
	// contains filtered or unexported fields
}

Server implements the framework provider server. Protocol specific implementations wrap this handling along with calling all request and response type conversions.

func (*Server) ApplyResourceChange added in v0.9.0

func (s *Server) ApplyResourceChange(ctx context.Context, req *ApplyResourceChangeRequest, resp *ApplyResourceChangeResponse)

ApplyResourceChange implements the framework server ApplyResourceChange RPC.

func (*Server) CallFunction added in v1.5.0

func (s *Server) CallFunction(ctx context.Context, req *CallFunctionRequest, resp *CallFunctionResponse)

CallFunction implements the framework server CallFunction RPC.

func (*Server) ConfigureProvider added in v0.9.0

func (s *Server) ConfigureProvider(ctx context.Context, req *provider.ConfigureRequest, resp *provider.ConfigureResponse)

ConfigureProvider implements the framework server ConfigureProvider RPC.

func (*Server) CreateResource added in v0.9.0

func (s *Server) CreateResource(ctx context.Context, req *CreateResourceRequest, resp *CreateResourceResponse)

CreateResource implements the framework server create request logic for the ApplyResourceChange RPC.

func (*Server) DataSource added in v0.12.0

func (s *Server) DataSource(ctx context.Context, typeName string) (datasource.DataSource, diag.Diagnostics)

DataSource returns the DataSource for a given type name.

func (*Server) DataSourceFuncs added in v0.12.0

func (s *Server) DataSourceFuncs(ctx context.Context) (map[string]func() datasource.DataSource, diag.Diagnostics)

DataSourceFuncs returns a map of DataSource functions. The results are cached on first use.

func (*Server) DataSourceMetadatas added in v1.4.0

func (s *Server) DataSourceMetadatas(ctx context.Context) ([]DataSourceMetadata, diag.Diagnostics)

DataSourceMetadatas returns a slice of DataSourceMetadata for the GetMetadata RPC.

func (*Server) DataSourceSchema added in v0.9.0

func (s *Server) DataSourceSchema(ctx context.Context, typeName string) (fwschema.Schema, diag.Diagnostics)

DataSourceSchema returns the DataSource Schema for the given type name and caches the result for later DataSource operations.

func (*Server) DataSourceSchemas added in v0.9.0

func (s *Server) DataSourceSchemas(ctx context.Context) (map[string]fwschema.Schema, diag.Diagnostics)

DataSourceSchemas returns a map of DataSource Schemas for the GetProviderSchema RPC without caching since not all schemas are guaranteed to be necessary for later provider operations. The schema implementations are also validated.

func (*Server) DeleteResource added in v0.9.0

func (s *Server) DeleteResource(ctx context.Context, req *DeleteResourceRequest, resp *DeleteResourceResponse)

DeleteResource implements the framework server delete request logic for the ApplyResourceChange RPC.

func (*Server) Function added in v1.5.0

func (s *Server) Function(ctx context.Context, name string) (function.Function, *function.FuncError)

Function returns the Function for a given name.

func (*Server) FunctionDefinition added in v1.5.0

func (s *Server) FunctionDefinition(ctx context.Context, name string) (function.Definition, *function.FuncError)

FunctionDefinition returns the Function Definition for the given name and caches the result for later Function operations.

func (*Server) FunctionDefinitions added in v1.5.0

func (s *Server) FunctionDefinitions(ctx context.Context) (map[string]function.Definition, diag.Diagnostics)

FunctionDefinitions returns a map of Function Definitions for the GetProviderSchema RPC without caching since not all definitions are guaranteed to be necessary for later provider operations. The definition implementations are also validated.

func (*Server) FunctionFuncs added in v1.5.0

func (s *Server) FunctionFuncs(ctx context.Context) (map[string]func() function.Function, diag.Diagnostics)

FunctionFuncs returns a map of Function functions. The results are cached on first use.

func (*Server) FunctionMetadatas added in v1.5.0

func (s *Server) FunctionMetadatas(ctx context.Context) ([]FunctionMetadata, diag.Diagnostics)

FunctionMetadatas returns a slice of FunctionMetadata for the GetMetadata RPC.

func (*Server) GetFunctions added in v1.5.0

func (s *Server) GetFunctions(ctx context.Context, req *GetFunctionsRequest, resp *GetFunctionsResponse)

GetFunctions implements the framework server GetFunctions RPC.

func (*Server) GetMetadata added in v1.4.0

func (s *Server) GetMetadata(ctx context.Context, req *GetMetadataRequest, resp *GetMetadataResponse)

GetMetadata implements the framework server GetMetadata RPC.

func (*Server) GetProviderSchema

func (s *Server) GetProviderSchema(ctx context.Context, req *GetProviderSchemaRequest, resp *GetProviderSchemaResponse)

GetProviderSchema implements the framework server GetProviderSchema RPC.

func (*Server) ImportResourceState added in v0.9.0

func (s *Server) ImportResourceState(ctx context.Context, req *ImportResourceStateRequest, resp *ImportResourceStateResponse)

ImportResourceState implements the framework server ImportResourceState RPC.

func (*Server) MoveResourceState added in v1.6.0

func (s *Server) MoveResourceState(ctx context.Context, req *MoveResourceStateRequest, resp *MoveResourceStateResponse)

MoveResourceState implements the framework server MoveResourceState RPC.

func (*Server) PlanResourceChange added in v0.9.0

func (s *Server) PlanResourceChange(ctx context.Context, req *PlanResourceChangeRequest, resp *PlanResourceChangeResponse)

PlanResourceChange implements the framework server PlanResourceChange RPC.

func (*Server) ProviderMetaSchema added in v0.9.0

func (s *Server) ProviderMetaSchema(ctx context.Context) (fwschema.Schema, diag.Diagnostics)

ProviderMetaSchema returns the Meta Schema associated with the Provider, if it implements the ProviderWithMetaSchema interface. The Schema and Diagnostics are cached on first use.

func (*Server) ProviderSchema added in v0.9.0

func (s *Server) ProviderSchema(ctx context.Context) (fwschema.Schema, diag.Diagnostics)

ProviderSchema returns the Schema associated with the Provider. The Schema and Diagnostics are cached on first use.

func (*Server) ProviderTypeName added in v1.4.1

func (s *Server) ProviderTypeName(ctx context.Context) string

ProviderTypeName returns the TypeName associated with the Provider. The TypeName is cached on first use.

func (*Server) ReadDataSource added in v0.9.0

func (s *Server) ReadDataSource(ctx context.Context, req *ReadDataSourceRequest, resp *ReadDataSourceResponse)

ReadDataSource implements the framework server ReadDataSource RPC.

func (*Server) ReadResource added in v0.9.0

func (s *Server) ReadResource(ctx context.Context, req *ReadResourceRequest, resp *ReadResourceResponse)

ReadResource implements the framework server ReadResource RPC.

func (*Server) Resource added in v0.12.0

func (s *Server) Resource(ctx context.Context, typeName string) (resource.Resource, diag.Diagnostics)

Resource returns the Resource for a given type name.

func (*Server) ResourceFuncs added in v0.12.0

func (s *Server) ResourceFuncs(ctx context.Context) (map[string]func() resource.Resource, diag.Diagnostics)

ResourceFuncs returns a map of Resource functions. The results are cached on first use.

func (*Server) ResourceMetadatas added in v1.4.0

func (s *Server) ResourceMetadatas(ctx context.Context) ([]ResourceMetadata, diag.Diagnostics)

ResourceMetadatas returns a slice of ResourceMetadata for the GetMetadata RPC.

func (*Server) ResourceSchema added in v0.9.0

func (s *Server) ResourceSchema(ctx context.Context, typeName string) (fwschema.Schema, diag.Diagnostics)

ResourceSchema returns the Resource Schema for the given type name and caches the result for later Resource operations.

func (*Server) ResourceSchemas added in v0.9.0

func (s *Server) ResourceSchemas(ctx context.Context) (map[string]fwschema.Schema, diag.Diagnostics)

ResourceSchemas returns a map of Resource Schemas for the GetProviderSchema RPC without caching since not all schemas are guaranteed to be necessary for later provider operations. The schema implementations are also validated.

func (*Server) ServerCapabilities added in v1.4.0

func (s *Server) ServerCapabilities() *ServerCapabilities

ServerCapabilities returns the server capabilities.

func (*Server) UpdateResource added in v0.9.0

func (s *Server) UpdateResource(ctx context.Context, req *UpdateResourceRequest, resp *UpdateResourceResponse)

UpdateResource implements the framework server update request logic for the ApplyResourceChange RPC.

func (*Server) UpgradeResourceState added in v0.9.0

func (s *Server) UpgradeResourceState(ctx context.Context, req *UpgradeResourceStateRequest, resp *UpgradeResourceStateResponse)

UpgradeResourceState implements the framework server UpgradeResourceState RPC.

func (*Server) ValidateDataSourceConfig added in v0.9.0

func (s *Server) ValidateDataSourceConfig(ctx context.Context, req *ValidateDataSourceConfigRequest, resp *ValidateDataSourceConfigResponse)

ValidateDataSourceConfig implements the framework server ValidateDataSourceConfig RPC.

func (*Server) ValidateProviderConfig added in v0.9.0

func (s *Server) ValidateProviderConfig(ctx context.Context, req *ValidateProviderConfigRequest, resp *ValidateProviderConfigResponse)

ValidateProviderConfig implements the framework server ValidateProviderConfig RPC.

func (*Server) ValidateResourceConfig added in v0.9.0

func (s *Server) ValidateResourceConfig(ctx context.Context, req *ValidateResourceConfigRequest, resp *ValidateResourceConfigResponse)

ValidateResourceConfig implements the framework server ValidateResourceConfig RPC.

type ServerCapabilities added in v0.10.0

type ServerCapabilities struct {
	// GetProviderSchemaOptional signals that the provider does not require the
	// GetProviderSchema RPC before other RPCs.
	//
	// This should always be enabled in framework providers and requires
	// Terraform 1.6 or later.
	GetProviderSchemaOptional bool

	// MoveResourceState signals that the provider is ready for the
	// MoveResourceState RPC.
	//
	// This should always be enabled in framework providers and requires
	// Terraform 1.8 or later.
	MoveResourceState bool

	// PlanDestroy signals that the provider is ready for the
	// PlanResourceChange RPC on resource destruction.
	//
	// This should always be enabled in framework providers and requires
	// Terraform 1.3 or later.
	PlanDestroy bool
}

ServerCapabilities is a combination of tfprotov5.ServerCapabilities and tfprotov6.ServerCapabilties, which may diverge over time. If that happens, the toproto5 conversion logic will handle the appropriate filtering and the proto5server/fwserver logic will need to account for missing features.

type UpdateResourceRequest added in v0.9.0

type UpdateResourceRequest struct {
	Config         *tfsdk.Config
	PlannedPrivate *privatestate.Data
	PlannedState   *tfsdk.Plan
	PriorState     *tfsdk.State
	ProviderMeta   *tfsdk.Config
	ResourceSchema fwschema.Schema
	Resource       resource.Resource
}

UpdateResourceRequest is the framework server request for an update request with the ApplyResourceChange RPC.

type UpdateResourceResponse added in v0.9.0

type UpdateResourceResponse struct {
	Diagnostics diag.Diagnostics
	NewState    *tfsdk.State
	Private     *privatestate.Data
}

UpdateResourceResponse is the framework server response for an update request with the ApplyResourceChange RPC.

type UpgradeResourceStateRequest added in v0.9.0

type UpgradeResourceStateRequest struct {
	// Using the tfprotov6 type here was a pragmatic effort decision around when
	// the framework introduced compatibility promises. This type was chosen as
	// it was readily available and trivial to convert between tfprotov5.
	//
	// Using a terraform-plugin-go type is not ideal for the framework as almost
	// all terraform-plugin-go types have framework abstractions, but if there
	// is ever a time where it makes sense to re-evaluate this decision, such as
	// a major version bump, it could be changed then.
	// Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/340
	RawState *tfprotov6.RawState

	ResourceSchema fwschema.Schema
	Resource       resource.Resource
	Version        int64
}

UpgradeResourceStateRequest is the framework server request for the UpgradeResourceState RPC.

type UpgradeResourceStateResponse added in v0.9.0

type UpgradeResourceStateResponse struct {
	Diagnostics   diag.Diagnostics
	UpgradedState *tfsdk.State
}

UpgradeResourceStateResponse is the framework server response for the UpgradeResourceState RPC.

type ValidateAttributeRequest added in v1.0.0

type ValidateAttributeRequest struct {
	// AttributePath contains the path of the attribute. Use this path for any
	// response diagnostics.
	AttributePath path.Path

	// AttributePathExpression contains the expression matching the exact path
	// of the attribute.
	AttributePathExpression path.Expression

	// AttributeConfig contains the value of the attribute in the configuration.
	AttributeConfig attr.Value

	// Config contains the entire configuration of the data source, provider, or resource.
	Config tfsdk.Config
}

ValidateAttributeRequest repesents a request for attribute validation.

type ValidateAttributeResponse added in v1.0.0

type ValidateAttributeResponse struct {
	// Diagnostics report errors or warnings related to validating the data
	// source configuration. An empty slice indicates success, with no warnings
	// or errors generated.
	Diagnostics diag.Diagnostics
}

ValidateAttributeResponse represents a response to a ValidateAttributeRequest. An instance of this response struct is automatically passed through to each AttributeValidator.

type ValidateDataSourceConfigRequest added in v0.9.0

type ValidateDataSourceConfigRequest struct {
	Config     *tfsdk.Config
	DataSource datasource.DataSource
}

ValidateDataSourceConfigRequest is the framework server request for the ValidateDataSourceConfig RPC.

type ValidateDataSourceConfigResponse added in v0.9.0

type ValidateDataSourceConfigResponse struct {
	Diagnostics diag.Diagnostics
}

ValidateDataSourceConfigResponse is the framework server response for the ValidateDataSourceConfig RPC.

type ValidateProviderConfigRequest added in v0.9.0

type ValidateProviderConfigRequest struct {
	Config *tfsdk.Config
}

ValidateProviderConfigRequest is the framework server request for the ValidateProviderConfig RPC.

type ValidateProviderConfigResponse added in v0.9.0

type ValidateProviderConfigResponse struct {
	PreparedConfig *tfsdk.Config
	Diagnostics    diag.Diagnostics
}

ValidateProviderConfigResponse is the framework server response for the ValidateProviderConfig RPC.

type ValidateResourceConfigRequest added in v0.9.0

type ValidateResourceConfigRequest struct {
	Config   *tfsdk.Config
	Resource resource.Resource
}

ValidateResourceConfigRequest is the framework server request for the ValidateResourceConfig RPC.

type ValidateResourceConfigResponse added in v0.9.0

type ValidateResourceConfigResponse struct {
	Diagnostics diag.Diagnostics
}

ValidateResourceConfigResponse is the framework server response for the ValidateResourceConfig RPC.

type ValidateSchemaRequest added in v0.9.0

type ValidateSchemaRequest struct {
	// Config contains the entire configuration of the data source, provider, or resource.
	//
	// This configuration may contain unknown values if a user uses
	// interpolation or other functionality that would prevent Terraform
	// from knowing the value at request time.
	Config tfsdk.Config
}

ValidateSchemaRequest repesents a request for validating a Schema.

type ValidateSchemaResponse added in v0.9.0

type ValidateSchemaResponse struct {
	// Diagnostics report errors or warnings related to validating the schema.
	// An empty slice indicates success, with no warnings or errors generated.
	Diagnostics diag.Diagnostics
}

ValidateSchemaResponse represents a response to a ValidateSchemaRequest.

Jump to

Keyboard shortcuts

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