Skip to content

Commit b799d5c

Browse files
Updated protocol to reflect core changes to protocol move request (#487)
* Updated protocol to reflect core changes to raw identity * RawIdentity Co-authored-by: Austin Valle <[email protected]> * RawIdentity Co-authored-by: Austin Valle <[email protected]> * Update tfprotov6/resource.go Co-authored-by: Austin Valle <[email protected]> * Update tfprotov5/resource.go Co-authored-by: Austin Valle <[email protected]> * Fixed bug from suggestions * Fixed bug from suggestions --------- Co-authored-by: Austin Valle <[email protected]>
1 parent e492882 commit b799d5c

File tree

15 files changed

+901
-915
lines changed

15 files changed

+901
-915
lines changed

tfprotov5/internal/fromproto/raw_identity.go

Lines changed: 0 additions & 20 deletions
This file was deleted.

tfprotov5/internal/fromproto/raw_identity_test.go

Lines changed: 0 additions & 18 deletions
This file was deleted.

tfprotov5/internal/fromproto/resource.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func UpgradeResourceIdentityRequest(in *tfplugin5.UpgradeResourceIdentity_Reques
4242
}
4343

4444
resp := &tfprotov5.UpgradeResourceIdentityRequest{
45-
RawIdentity: RawIdentity(in.RawIdentity),
45+
RawIdentity: RawState(in.RawIdentity),
4646
TypeName: in.TypeName,
4747
Version: in.Version,
4848
}
@@ -131,7 +131,7 @@ func MoveResourceStateRequest(in *tfplugin5.MoveResourceState_Request) *tfprotov
131131
SourceState: RawState(in.SourceState),
132132
SourceTypeName: in.SourceTypeName,
133133
TargetTypeName: in.TargetTypeName,
134-
SourceIdentity: ResourceIdentityData(in.SourceIdentity),
134+
SourceIdentity: RawState(in.SourceIdentity),
135135
}
136136

137137
return resp

tfprotov5/internal/fromproto/resource_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ func TestMoveResourceStateRequest(t *testing.T) {
230230
},
231231
"SourceIdentity": {
232232
in: &tfplugin5.MoveResourceState_Request{
233-
SourceIdentity: testTfplugin5ResourceIdentityData(),
233+
SourceIdentity: testTfplugin5RawState(t, []byte("{}")),
234234
},
235235
expected: &tfprotov5.MoveResourceStateRequest{
236-
SourceIdentity: testTfprotov5ResourceIdentityData(),
236+
SourceIdentity: testTfprotov5RawState(t, []byte("{}")),
237237
},
238238
},
239239
}
@@ -502,10 +502,10 @@ func TestUpgradeResourceIdentityRequest(t *testing.T) {
502502
},
503503
"RawIdentity": {
504504
in: &tfplugin5.UpgradeResourceIdentity_Request{
505-
RawIdentity: []byte("{}"),
505+
RawIdentity: testTfplugin5RawState(t, []byte("{}")),
506506
},
507507
expected: &tfprotov5.UpgradeResourceIdentityRequest{
508-
RawIdentity: testTfprotov5RawIdentity(t, []byte("{}")),
508+
RawIdentity: testTfprotov5RawState(t, []byte("{}")),
509509
},
510510
},
511511
"TypeName": {

tfprotov5/internal/tfplugin5/tfplugin5.pb.go

Lines changed: 458 additions & 439 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tfprotov5/internal/tfplugin5/tfplugin5.proto

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,14 @@ message MoveResourceState {
634634
// The private state of the resource being moved.
635635
bytes source_private = 6;
636636

637-
ResourceIdentityData source_identity = 7;
637+
// The raw identity of the resource being moved. Only the json field is
638+
// populated, as there should be no legacy providers using the flatmap
639+
// format that support newly introduced RPCs.
640+
RawState source_identity = 7;
641+
642+
// The identity schema version of the resource type that the resource
643+
// is being moved from.
644+
int64 source_identity_schema_version = 8;
638645
}
639646

640647
message Response {
@@ -807,7 +814,7 @@ message UpgradeResourceIdentity {
807814
// not have access to the identity schema of prior_version, so it's the
808815
// provider's responsibility to interpret this value using the
809816
// appropriate older schema. The raw_identity will be json encoded.
810-
bytes raw_identity = 3;
817+
RawState raw_identity = 3;
811818
}
812819
message Response {
813820
// upgraded_identity returns the upgraded resource identity data

tfprotov5/resource.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ type UpgradeResourceIdentityRequest struct {
145145
// RawIdentity is the identity state as Terraform sees it right now. See the
146146
// documentation for `RawIdentity` for information on how to work with the
147147
// data it contains.
148-
RawIdentity *RawIdentity
148+
RawIdentity *RawState
149149
}
150150

151151
type UpgradeResourceIdentityResponse struct {
@@ -609,7 +609,12 @@ type MoveResourceStateRequest struct {
609609
TargetTypeName string
610610

611611
// SourceIdentity is the identity of the source resource.
612-
SourceIdentity *ResourceIdentityData
612+
//
613+
// Only the underlying JSON field is populated.
614+
SourceIdentity *RawState
615+
616+
// SourceIdentitySchemaVersion is the version of the source resource state.
617+
SourceIdentitySchemaVersion int64
613618
}
614619

615620
// MoveResourceStateResponse is the response from the provider containing

tfprotov6/internal/fromproto/raw_identity.go

Lines changed: 0 additions & 20 deletions
This file was deleted.

tfprotov6/internal/fromproto/raw_identity_test.go

Lines changed: 0 additions & 18 deletions
This file was deleted.

tfprotov6/internal/fromproto/resource.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func UpgradeResourceIdentityRequest(in *tfplugin6.UpgradeResourceIdentity_Reques
4242
}
4343

4444
resp := &tfprotov6.UpgradeResourceIdentityRequest{
45-
RawIdentity: RawIdentity(in.RawIdentity),
45+
RawIdentity: RawState(in.RawIdentity),
4646
TypeName: in.TypeName,
4747
Version: in.Version,
4848
}
@@ -131,7 +131,7 @@ func MoveResourceStateRequest(in *tfplugin6.MoveResourceState_Request) *tfprotov
131131
SourceState: RawState(in.SourceState),
132132
SourceTypeName: in.SourceTypeName,
133133
TargetTypeName: in.TargetTypeName,
134-
SourceIdentity: ResourceIdentityData(in.SourceIdentity),
134+
SourceIdentity: RawState(in.SourceIdentity),
135135
}
136136

137137
return resp

0 commit comments

Comments
 (0)