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

all: Update tfproto translation servers to support deferred actions #237

Merged
merged 2 commits into from
May 8, 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
5 changes: 5 additions & 0 deletions .changes/unreleased/ENHANCEMENTS-20240507-180758.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: ENHANCEMENTS
body: 'tf5to6server: Add deferred action request and response fields to RPC translations'
time: 2024-05-07T18:07:58.792141-04:00
custom:
Issue: "237"
5 changes: 5 additions & 0 deletions .changes/unreleased/ENHANCEMENTS-20240507-180817.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: ENHANCEMENTS
body: 'tf6to5server: Add deferred action request and response fields to RPC translations'
time: 2024-05-07T18:08:17.113209-04:00
custom:
Issue: "237"
115 changes: 98 additions & 17 deletions internal/tfprotov5tov6/tfprotov5tov6.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,24 @@ func ConfigureProviderRequest(in *tfprotov5.ConfigureProviderRequest) *tfprotov6
}

return &tfprotov6.ConfigureProviderRequest{
Config: DynamicValue(in.Config),
TerraformVersion: in.TerraformVersion,
ClientCapabilities: ConfigureProviderClientCapabilities(in.ClientCapabilities),
Config: DynamicValue(in.Config),
TerraformVersion: in.TerraformVersion,
}
}

func ConfigureProviderClientCapabilities(in *tfprotov5.ConfigureProviderClientCapabilities) *tfprotov6.ConfigureProviderClientCapabilities {
if in == nil {
return nil
}

resp := &tfprotov6.ConfigureProviderClientCapabilities{
DeferralAllowed: in.DeferralAllowed,
}

return resp
}

func ConfigureProviderResponse(in *tfprotov5.ConfigureProviderResponse) *tfprotov6.ConfigureProviderResponse {
if in == nil {
return nil
Expand All @@ -91,6 +104,18 @@ func DataSourceMetadata(in tfprotov5.DataSourceMetadata) tfprotov6.DataSourceMet
}
}

func Deferred(in *tfprotov5.Deferred) *tfprotov6.Deferred {
if in == nil {
return nil
}

resp := &tfprotov6.Deferred{
Reason: tfprotov6.DeferredReason(in.Reason),
}

return resp
}

func Diagnostics(in []*tfprotov5.Diagnostic) []*tfprotov6.Diagnostic {
if in == nil {
return nil
Expand Down Expand Up @@ -301,9 +326,22 @@ func ImportResourceStateRequest(in *tfprotov5.ImportResourceStateRequest) *tfpro
}

return &tfprotov6.ImportResourceStateRequest{
ID: in.ID,
TypeName: in.TypeName,
ClientCapabilities: ImportResourceStateClientCapabilities(in.ClientCapabilities),
ID: in.ID,
TypeName: in.TypeName,
}
}

func ImportResourceStateClientCapabilities(in *tfprotov5.ImportResourceStateClientCapabilities) *tfprotov6.ImportResourceStateClientCapabilities {
if in == nil {
return nil
}

resp := &tfprotov6.ImportResourceStateClientCapabilities{
DeferralAllowed: in.DeferralAllowed,
}

return resp
}

func ImportResourceStateResponse(in *tfprotov5.ImportResourceStateResponse) *tfprotov6.ImportResourceStateResponse {
Expand All @@ -312,6 +350,7 @@ func ImportResourceStateResponse(in *tfprotov5.ImportResourceStateResponse) *tfp
}

return &tfprotov6.ImportResourceStateResponse{
Deferred: Deferred(in.Deferred),
Diagnostics: Diagnostics(in.Diagnostics),
ImportedResources: ImportedResources(in.ImportedResources),
}
Expand Down Expand Up @@ -373,21 +412,35 @@ func PlanResourceChangeRequest(in *tfprotov5.PlanResourceChangeRequest) *tfproto
}

return &tfprotov6.PlanResourceChangeRequest{
Config: DynamicValue(in.Config),
PriorPrivate: in.PriorPrivate,
PriorState: DynamicValue(in.PriorState),
ProposedNewState: DynamicValue(in.ProposedNewState),
ProviderMeta: DynamicValue(in.ProviderMeta),
TypeName: in.TypeName,
ClientCapabilities: PlanResourceChangeClientCapabilities(in.ClientCapabilities),
Config: DynamicValue(in.Config),
PriorPrivate: in.PriorPrivate,
PriorState: DynamicValue(in.PriorState),
ProposedNewState: DynamicValue(in.ProposedNewState),
ProviderMeta: DynamicValue(in.ProviderMeta),
TypeName: in.TypeName,
}
}

func PlanResourceChangeClientCapabilities(in *tfprotov5.PlanResourceChangeClientCapabilities) *tfprotov6.PlanResourceChangeClientCapabilities {
if in == nil {
return nil
}

resp := &tfprotov6.PlanResourceChangeClientCapabilities{
DeferralAllowed: in.DeferralAllowed,
}

return resp
}

func PlanResourceChangeResponse(in *tfprotov5.PlanResourceChangeResponse) *tfprotov6.PlanResourceChangeResponse {
if in == nil {
return nil
}

return &tfprotov6.PlanResourceChangeResponse{
Deferred: Deferred(in.Deferred),
Diagnostics: Diagnostics(in.Diagnostics),
PlannedPrivate: in.PlannedPrivate,
PlannedState: DynamicValue(in.PlannedState),
Expand All @@ -412,18 +465,32 @@ func ReadDataSourceRequest(in *tfprotov5.ReadDataSourceRequest) *tfprotov6.ReadD
return nil
}
return &tfprotov6.ReadDataSourceRequest{
Config: DynamicValue(in.Config),
ProviderMeta: DynamicValue(in.ProviderMeta),
TypeName: in.TypeName,
ClientCapabilities: ReadDataSourceClientCapabilities(in.ClientCapabilities),
Config: DynamicValue(in.Config),
ProviderMeta: DynamicValue(in.ProviderMeta),
TypeName: in.TypeName,
}
}

func ReadDataSourceClientCapabilities(in *tfprotov5.ReadDataSourceClientCapabilities) *tfprotov6.ReadDataSourceClientCapabilities {
if in == nil {
return nil
}

resp := &tfprotov6.ReadDataSourceClientCapabilities{
DeferralAllowed: in.DeferralAllowed,
}

return resp
}

func ReadDataSourceResponse(in *tfprotov5.ReadDataSourceResponse) *tfprotov6.ReadDataSourceResponse {
if in == nil {
return nil
}

return &tfprotov6.ReadDataSourceResponse{
Deferred: Deferred(in.Deferred),
Diagnostics: Diagnostics(in.Diagnostics),
State: DynamicValue(in.State),
}
Expand All @@ -435,19 +502,33 @@ func ReadResourceRequest(in *tfprotov5.ReadResourceRequest) *tfprotov6.ReadResou
}

return &tfprotov6.ReadResourceRequest{
CurrentState: DynamicValue(in.CurrentState),
Private: in.Private,
ProviderMeta: DynamicValue(in.ProviderMeta),
TypeName: in.TypeName,
ClientCapabilities: ReadResourceClientCapabilities(in.ClientCapabilities),
CurrentState: DynamicValue(in.CurrentState),
Private: in.Private,
ProviderMeta: DynamicValue(in.ProviderMeta),
TypeName: in.TypeName,
}
}

func ReadResourceClientCapabilities(in *tfprotov5.ReadResourceClientCapabilities) *tfprotov6.ReadResourceClientCapabilities {
if in == nil {
return nil
}

resp := &tfprotov6.ReadResourceClientCapabilities{
DeferralAllowed: in.DeferralAllowed,
}

return resp
}

func ReadResourceResponse(in *tfprotov5.ReadResourceResponse) *tfprotov6.ReadResourceResponse {
if in == nil {
return nil
}

return &tfprotov6.ReadResourceResponse{
Deferred: Deferred(in.Deferred),
Diagnostics: Diagnostics(in.Diagnostics),
NewState: DynamicValue(in.NewState),
Private: in.Private,
Expand Down
Loading
Loading