fwserver

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MPL-2.0 Imports: 21 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 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 AttributeValidateNestedAttributes added in v0.9.0

func AttributeValidateNestedAttributes(ctx context.Context, a fwschema.Attribute, req tfsdk.ValidateAttributeRequest, resp *tfsdk.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 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 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 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 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 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 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 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 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
	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 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 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 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) 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) DataSourceSchema added in v0.9.0

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

DataSourceSchema returns the Schema associated with the DataSourceType for the given type name.

func (*Server) DataSourceSchemas added in v0.9.0

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

DataSourceSchemas returns the map of DataSourceType Schemas. The results are cached on first use.

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) 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) 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) 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) ResourceSchema added in v0.9.0

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

ResourceSchema returns the Schema associated with the ResourceType for the given type name.

func (*Server) ResourceSchemas added in v0.9.0

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

ResourceSchemas returns the map of ResourceType Schemas. The results are cached on first use.

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 {
	// 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 {
	// TODO: Create framework defined type that is not protocol specific.
	// 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 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