Skip to content

Commit bd50706

Browse files
authored
tfprotov5+tfprotov6: Initial MoveResourceState support (#364)
Reference: #362 Reference: #363 The next version of the plugin protocol (5.5/6.5) includes support for moving resource state. This change introduces the initial implementation of that support including: - Updated Protocol Buffers definitions - Re-generated Protocol Buffers Go code - Initial implementations of `tfprotov5` and `tfprotov6` package abstractions and wiring between those abstractions and the Protocol Buffers generated Go code - Initial implementations of `tfprotov5/tf5server` and `tfprotov6/tf6server` for the new `MoveResourceState` RPC This temporarily will not require `ProviderServer` implementations to include `MoveResourceState` implementation, however that change will occur in a subsequent release.
1 parent 7553bff commit bd50706

24 files changed

+2577
-1553
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: FEATURES
2+
body: 'tfprotov5+tfprotov6: Upgraded protocols and added types to support the `MoveResourceState`
3+
RPC'
4+
time: 2024-01-12T15:33:55.940212-08:00
5+
custom:
6+
Issue: "364"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: NOTES
2+
body: 'tfprotov5+tfprotov6: An upcoming release will require the MoveResourceState
3+
implementation as part of ResourceServer'
4+
time: 2024-01-12T15:35:01.843365-08:00
5+
custom:
6+
Issue: "364"

tfprotov5/internal/fromproto/resource.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,11 @@ func ValidateResourceTypeConfigResponse(in *tfplugin5.ValidateResourceTypeConfig
4242

4343
func UpgradeResourceStateRequest(in *tfplugin5.UpgradeResourceState_Request) (*tfprotov5.UpgradeResourceStateRequest, error) {
4444
resp := &tfprotov5.UpgradeResourceStateRequest{
45+
RawState: RawState(in.RawState),
4546
TypeName: in.TypeName,
4647
Version: in.Version,
4748
}
48-
if in.RawState != nil {
49-
resp.RawState = RawState(in.RawState)
50-
}
49+
5150
return resp, nil
5251
}
5352

@@ -219,3 +218,15 @@ func ImportedResources(in []*tfplugin5.ImportResourceState_ImportedResource) ([]
219218
}
220219
return resp, nil
221220
}
221+
222+
func MoveResourceStateRequest(in *tfplugin5.MoveResourceState_Request) (*tfprotov5.MoveResourceStateRequest, error) {
223+
resp := &tfprotov5.MoveResourceStateRequest{
224+
SourceProviderAddress: in.SourceProviderAddress,
225+
SourceSchemaVersion: in.SourceSchemaVersion,
226+
SourceState: RawState(in.SourceState),
227+
SourceTypeName: in.SourceTypeName,
228+
TargetTypeName: in.TargetTypeName,
229+
}
230+
231+
return resp, nil
232+
}

tfprotov5/internal/fromproto/server_capabilities.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ func ServerCapabilities(in *tfplugin5.ServerCapabilities) *tfprotov5.ServerCapab
1515

1616
return &tfprotov5.ServerCapabilities{
1717
GetProviderSchemaOptional: in.GetProviderSchemaOptional,
18+
MoveResourceState: in.MoveResourceState,
1819
PlanDestroy: in.PlanDestroy,
1920
}
2021
}

tfprotov5/internal/fromproto/state.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import (
99
)
1010

1111
func RawState(in *tfplugin5.RawState) *tfprotov5.RawState {
12+
if in == nil {
13+
return nil
14+
}
15+
1216
return &tfprotov5.RawState{
1317
JSON: in.Json,
1418
Flatmap: in.Flatmap,

0 commit comments

Comments
 (0)