Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tfprotov5+tfprotov6: Initial MoveResourceState support #364

Merged
merged 4 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/FEATURES-20240112-153355.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: FEATURES
body: 'tfprotov5+tfprotov6: Upgraded protocols and added types to support the `MoveResourceState`
RPC'
time: 2024-01-12T15:33:55.940212-08:00
custom:
Issue: "364"
6 changes: 6 additions & 0 deletions .changes/unreleased/NOTES-20240112-153501.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: NOTES
body: 'tfprotov5+tfprotov6: An upcoming release will require the MoveResourceState
implementation as part of ResourceServer'
time: 2024-01-12T15:35:01.843365-08:00
custom:
Issue: "364"
17 changes: 14 additions & 3 deletions tfprotov5/internal/fromproto/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ func ValidateResourceTypeConfigResponse(in *tfplugin5.ValidateResourceTypeConfig

func UpgradeResourceStateRequest(in *tfplugin5.UpgradeResourceState_Request) (*tfprotov5.UpgradeResourceStateRequest, error) {
resp := &tfprotov5.UpgradeResourceStateRequest{
RawState: RawState(in.RawState),
TypeName: in.TypeName,
Version: in.Version,
}
if in.RawState != nil {
resp.RawState = RawState(in.RawState)
}

return resp, nil
}

Expand Down Expand Up @@ -219,3 +218,15 @@ func ImportedResources(in []*tfplugin5.ImportResourceState_ImportedResource) ([]
}
return resp, nil
}

func MoveResourceStateRequest(in *tfplugin5.MoveResourceState_Request) (*tfprotov5.MoveResourceStateRequest, error) {
resp := &tfprotov5.MoveResourceStateRequest{
SourceProviderAddress: in.SourceProviderAddress,
SourceSchemaVersion: in.SourceSchemaVersion,
SourceState: RawState(in.SourceState),
SourceTypeName: in.SourceTypeName,
TargetTypeName: in.TargetTypeName,
}

return resp, nil
}
1 change: 1 addition & 0 deletions tfprotov5/internal/fromproto/server_capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func ServerCapabilities(in *tfplugin5.ServerCapabilities) *tfprotov5.ServerCapab

return &tfprotov5.ServerCapabilities{
GetProviderSchemaOptional: in.GetProviderSchemaOptional,
MoveResourceState: in.MoveResourceState,
PlanDestroy: in.PlanDestroy,
}
}
4 changes: 4 additions & 0 deletions tfprotov5/internal/fromproto/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import (
)

func RawState(in *tfplugin5.RawState) *tfprotov5.RawState {
if in == nil {
return nil
}

return &tfprotov5.RawState{
JSON: in.Json,
Flatmap: in.Flatmap,
Expand Down
Loading
Loading