Skip to content

Commit 5206b46

Browse files
authored
tfprotov5+tfprotov6: Include private state in MoveResourceState (#372)
Reference: hashicorp/terraform#34575 To match upstream changes. No changelog is necessary as this is unreleased.
1 parent c9a4f80 commit 5206b46

File tree

14 files changed

+481
-371
lines changed

14 files changed

+481
-371
lines changed

tfprotov5/internal/fromproto/resource.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ func MoveResourceStateRequest(in *tfplugin5.MoveResourceState_Request) *tfprotov
103103
}
104104

105105
resp := &tfprotov5.MoveResourceStateRequest{
106+
SourcePrivate: in.SourcePrivate,
106107
SourceProviderAddress: in.SourceProviderAddress,
107108
SourceSchemaVersion: in.SourceSchemaVersion,
108109
SourceState: RawState(in.SourceState),

tfprotov5/internal/fromproto/resource_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ func TestMoveResourceStateRequest(t *testing.T) {
155155
in: &tfplugin5.MoveResourceState_Request{},
156156
expected: &tfprotov5.MoveResourceStateRequest{},
157157
},
158+
"SourcePrivate": {
159+
in: &tfplugin5.MoveResourceState_Request{
160+
SourcePrivate: []byte(`{}`),
161+
},
162+
expected: &tfprotov5.MoveResourceStateRequest{
163+
SourcePrivate: []byte(`{}`),
164+
},
165+
},
158166
"SourceProviderAddress": {
159167
in: &tfplugin5.MoveResourceState_Request{
160168
SourceProviderAddress: "test",

tfprotov5/internal/tfplugin5/tfplugin5.pb.go

Lines changed: 235 additions & 212 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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,13 +490,20 @@ message MoveResourceState {
490490

491491
// The resource type that the resource is being moved to.
492492
string target_type_name = 5;
493+
494+
// The private state of the resource being moved.
495+
bytes source_private = 6;
493496
}
497+
494498
message Response {
495499
// The state of the resource after it has been moved.
496500
DynamicValue target_state = 1;
497501

498502
// Any diagnostics that occurred during the move.
499503
repeated Diagnostic diagnostics = 2;
504+
505+
// The private state of the resource after it has been moved.
506+
bytes target_private = 3;
500507
}
501508
}
502509

tfprotov5/internal/toproto/resource.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ func MoveResourceState_Response(in *tfprotov5.MoveResourceStateResponse) *tfplug
133133
}
134134

135135
resp := &tfplugin5.MoveResourceState_Response{
136-
Diagnostics: Diagnostics(in.Diagnostics),
137-
TargetState: DynamicValue(in.TargetState),
136+
Diagnostics: Diagnostics(in.Diagnostics),
137+
TargetPrivate: in.TargetPrivate,
138+
TargetState: DynamicValue(in.TargetState),
138139
}
139140

140141
return resp

tfprotov5/internal/toproto/resource_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,15 @@ func TestMoveResourceState_Response(t *testing.T) {
386386
},
387387
},
388388
},
389+
"TargetPrivate": {
390+
in: &tfprotov5.MoveResourceStateResponse{
391+
TargetPrivate: []byte(`{}`),
392+
},
393+
expected: &tfplugin5.MoveResourceState_Response{
394+
Diagnostics: []*tfplugin5.Diagnostic{},
395+
TargetPrivate: []byte(`{}`),
396+
},
397+
},
389398
"TargetState": {
390399
in: &tfprotov5.MoveResourceStateResponse{
391400
TargetState: testTfprotov5DynamicValue(),

tfprotov5/resource.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,9 @@ type ImportedResource struct {
510510
// must have enabled the MoveResourceState server capability to enable these
511511
// requests.
512512
type MoveResourceStateRequest struct {
513+
// SourcePrivate is the private state of the source resource.
514+
SourcePrivate []byte
515+
513516
// SourceProviderAddress is the address of the provider for the source
514517
// resource type.
515518
SourceProviderAddress string
@@ -532,6 +535,9 @@ type MoveResourceStateRequest struct {
532535
// MoveResourceStateResponse is the response from the provider containing
533536
// the moved state for the given resource.
534537
type MoveResourceStateResponse struct {
538+
// TargetPrivate is the target resource private state after the move.
539+
TargetPrivate []byte
540+
535541
// TargetState is the target resource state after the move.
536542
TargetState *DynamicValue
537543

tfprotov6/internal/fromproto/resource.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ func MoveResourceStateRequest(in *tfplugin6.MoveResourceState_Request) *tfprotov
103103
}
104104

105105
resp := &tfprotov6.MoveResourceStateRequest{
106+
SourcePrivate: in.SourcePrivate,
106107
SourceProviderAddress: in.SourceProviderAddress,
107108
SourceSchemaVersion: in.SourceSchemaVersion,
108109
SourceState: RawState(in.SourceState),

tfprotov6/internal/fromproto/resource_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ func TestMoveResourceStateRequest(t *testing.T) {
155155
in: &tfplugin6.MoveResourceState_Request{},
156156
expected: &tfprotov6.MoveResourceStateRequest{},
157157
},
158+
"SourcePrivate": {
159+
in: &tfplugin6.MoveResourceState_Request{
160+
SourcePrivate: []byte(`{}`),
161+
},
162+
expected: &tfprotov6.MoveResourceStateRequest{
163+
SourcePrivate: []byte(`{}`),
164+
},
165+
},
158166
"SourceProviderAddress": {
159167
in: &tfplugin6.MoveResourceState_Request{
160168
SourceProviderAddress: "test",

tfprotov6/internal/tfplugin6/tfplugin6.pb.go

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

tfprotov6/internal/tfplugin6/tfplugin6.proto

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,13 +507,20 @@ message MoveResourceState {
507507

508508
// The resource type that the resource is being moved to.
509509
string target_type_name = 5;
510+
511+
// The private state of the resource being moved.
512+
bytes source_private = 6;
510513
}
514+
511515
message Response {
512516
// The state of the resource after it has been moved.
513517
DynamicValue target_state = 1;
514518

515519
// Any diagnostics that occurred during the move.
516520
repeated Diagnostic diagnostics = 2;
521+
522+
// The private state of the resource after it has been moved.
523+
bytes target_private = 3;
517524
}
518525
}
519526

tfprotov6/internal/toproto/resource.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ func MoveResourceState_Response(in *tfprotov6.MoveResourceStateResponse) *tfplug
133133
}
134134

135135
resp := &tfplugin6.MoveResourceState_Response{
136-
Diagnostics: Diagnostics(in.Diagnostics),
137-
TargetState: DynamicValue(in.TargetState),
136+
Diagnostics: Diagnostics(in.Diagnostics),
137+
TargetPrivate: in.TargetPrivate,
138+
TargetState: DynamicValue(in.TargetState),
138139
}
139140

140141
return resp

tfprotov6/internal/toproto/resource_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,15 @@ func TestMoveResourceState_Response(t *testing.T) {
386386
},
387387
},
388388
},
389+
"TargetPrivate": {
390+
in: &tfprotov6.MoveResourceStateResponse{
391+
TargetPrivate: []byte(`{}`),
392+
},
393+
expected: &tfplugin6.MoveResourceState_Response{
394+
Diagnostics: []*tfplugin6.Diagnostic{},
395+
TargetPrivate: []byte(`{}`),
396+
},
397+
},
389398
"TargetState": {
390399
in: &tfprotov6.MoveResourceStateResponse{
391400
TargetState: testTfprotov6DynamicValue(),

tfprotov6/resource.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,9 @@ type ImportedResource struct {
507507
// must have enabled the MoveResourceState server capability to enable these
508508
// requests.
509509
type MoveResourceStateRequest struct {
510+
// SourcePrivate is the private state of the source resource.
511+
SourcePrivate []byte
512+
510513
// SourceProviderAddress is the address of the provider for the source
511514
// resource type.
512515
SourceProviderAddress string
@@ -529,6 +532,9 @@ type MoveResourceStateRequest struct {
529532
// MoveResourceStateResponse is the response from the provider containing
530533
// the moved state for the given resource.
531534
type MoveResourceStateResponse struct {
535+
// TargetPrivate is the target resource private state after the move.
536+
TargetPrivate []byte
537+
532538
// TargetState is the target resource state after the move.
533539
TargetState *DynamicValue
534540

0 commit comments

Comments
 (0)