Skip to content

Commit

Permalink
tfprotov5+tfprotov6: Reinstate ResourceServerWithMoveResourceState te…
Browse files Browse the repository at this point in the history
…mporary interface
  • Loading branch information
bflad committed Mar 12, 2024
1 parent e52edf5 commit 56e454f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
7 changes: 3 additions & 4 deletions .changes/unreleased/BREAKING CHANGES-20240311-093436.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
kind: BREAKING CHANGES
body: 'tfprotov5+tfprotov6: Moved `MoveResourceState` method to `ResourceServer`
and removed temporary `ResourceServerWithMoveResourceState` interface.
Implementations not needing move state support can return errors from the
`MoveResourceState` method.'
body: 'tfprotov5+tfprotov6: `MoveResourceState` method is now required in
`ResourceServer`. Implementations not needing move state support can return
errors from the `MoveResourceState` method.'
time: 2024-03-11T09:34:36.800884-04:00
custom:
Issue: "388"
20 changes: 20 additions & 0 deletions tfprotov5/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,26 @@ type ResourceServer interface {
MoveResourceState(context.Context, *MoveResourceStateRequest) (*MoveResourceStateResponse, error)
}

// ResourceServerWithMoveResourceState is a temporary interface for servers
// to implement MoveResourceState RPC handling.
//
// Deprecated: This interface will be removed in a future version. Use
// ResourceServer instead.
type ResourceServerWithMoveResourceState interface {
ResourceServer

// MoveResourceState is called when Terraform is asked to change a resource
// type for an existing resource. The provider must accept the change as
// valid by ensuring the source resource type, schema version, and provider
// address are compatible to convert the source state into the target
// resource type and latest state version.
//
// This functionality is only supported in Terraform 1.8 and later. The
// provider must have enabled the MoveResourceState server capability to
// enable these requests.
MoveResourceState(context.Context, *MoveResourceStateRequest) (*MoveResourceStateResponse, error)
}

// ValidateResourceTypeConfigRequest is the request Terraform sends when it
// wants to validate a resource's configuration.
type ValidateResourceTypeConfigRequest struct {
Expand Down
20 changes: 20 additions & 0 deletions tfprotov6/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,26 @@ type ResourceServer interface {
MoveResourceState(context.Context, *MoveResourceStateRequest) (*MoveResourceStateResponse, error)
}

// ResourceServerWithMoveResourceState is a temporary interface for servers
// to implement MoveResourceState RPC handling.
//
// Deprecated: This interface will be removed in a future version. Use
// ResourceServer instead.
type ResourceServerWithMoveResourceState interface {
ResourceServer

// MoveResourceState is called when Terraform is asked to change a resource
// type for an existing resource. The provider must accept the change as
// valid by ensuring the source resource type, schema version, and provider
// address are compatible to convert the source state into the target
// resource type and latest state version.
//
// This functionality is only supported in Terraform 1.8 and later. The
// provider must have enabled the MoveResourceState server capability to
// enable these requests.
MoveResourceState(context.Context, *MoveResourceStateRequest) (*MoveResourceStateResponse, error)
}

// ValidateResourceConfigRequest is the request Terraform sends when it
// wants to validate a resource's configuration.
type ValidateResourceConfigRequest struct {
Expand Down

0 comments on commit 56e454f

Please sign in to comment.