Skip to content

Commit 34080cf

Browse files
authored
Merge pull request #11 from hashicorp/paddy_legacy_type_system
Support the legacy type system.
2 parents 4a37f3d + 0df8bcd commit 34080cf

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

tfprotov5/internal/fromproto/resource.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ func PlanResourceChangeRequest(in *tfplugin5.PlanResourceChange_Request) (*tfpro
9999

100100
func PlanResourceChangeResponse(in *tfplugin5.PlanResourceChange_Response) (*tfprotov5.PlanResourceChangeResponse, error) {
101101
resp := &tfprotov5.PlanResourceChangeResponse{
102-
PlannedPrivate: in.PlannedPrivate,
102+
PlannedPrivate: in.PlannedPrivate,
103+
UnsafeToUseLegacyTypeSystem: in.LegacyTypeSystem,
103104
}
104105
attributePaths, err := AttributePaths(in.RequiresReplace)
105106
if err != nil {
@@ -139,7 +140,8 @@ func ApplyResourceChangeRequest(in *tfplugin5.ApplyResourceChange_Request) (*tfp
139140

140141
func ApplyResourceChangeResponse(in *tfplugin5.ApplyResourceChange_Response) (*tfprotov5.ApplyResourceChangeResponse, error) {
141142
resp := &tfprotov5.ApplyResourceChangeResponse{
142-
Private: in.Private,
143+
Private: in.Private,
144+
UnsafeToUseLegacyTypeSystem: in.LegacyTypeSystem,
143145
}
144146
diags, err := Diagnostics(in.Diagnostics)
145147
if err != nil {

tfprotov5/internal/toproto/resource.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ func PlanResourceChange_Request(in *tfprotov5.PlanResourceChangeRequest) (*tfplu
9797

9898
func PlanResourceChange_Response(in *tfprotov5.PlanResourceChangeResponse) (*tfplugin5.PlanResourceChange_Response, error) {
9999
resp := &tfplugin5.PlanResourceChange_Response{
100-
PlannedPrivate: in.PlannedPrivate,
100+
PlannedPrivate: in.PlannedPrivate,
101+
LegacyTypeSystem: in.UnsafeToUseLegacyTypeSystem, //nolint:staticcheck
101102
}
102103
requiresReplace, err := AttributePaths(in.RequiresReplace)
103104
if err != nil {
@@ -137,7 +138,8 @@ func ApplyResourceChange_Request(in *tfprotov5.ApplyResourceChangeRequest) (*tfp
137138

138139
func ApplyResourceChange_Response(in *tfprotov5.ApplyResourceChangeResponse) (*tfplugin5.ApplyResourceChange_Response, error) {
139140
resp := &tfplugin5.ApplyResourceChange_Response{
140-
Private: in.Private,
141+
Private: in.Private,
142+
LegacyTypeSystem: in.UnsafeToUseLegacyTypeSystem, //nolint:staticcheck
141143
}
142144
diags, err := Diagnostics(in.Diagnostics)
143145
if err != nil {

tfprotov5/resource.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@ type PlanResourceChangeResponse struct {
6262
RequiresReplace []*tftypes.AttributePath
6363
PlannedPrivate []byte
6464
Diagnostics []*Diagnostic
65+
66+
// This field should only be set by hashicorp/terraform-plugin-sdk.
67+
// It modifies Terraform's behavior to work with the legacy
68+
// expectations of that SDK.
69+
//
70+
// Nobody else should use this. Ever. For any reason. Just don't do it.
71+
//
72+
// We have to expose it here for terraform-plugin-sdk to be muxable, or
73+
// we wouldn't even be including it in this type. Don't use it. It may
74+
// go away or change behavior on you with no warning. It is
75+
// explicitly unsupported and not part of our SemVer guarantees.
76+
//
77+
// Deprecated: Really, just don't use this, you don't need it.
78+
UnsafeToUseLegacyTypeSystem bool
6579
}
6680

6781
type ApplyResourceChangeRequest struct {
@@ -77,6 +91,20 @@ type ApplyResourceChangeResponse struct {
7791
NewState *DynamicValue
7892
Private []byte
7993
Diagnostics []*Diagnostic
94+
95+
// This field should only be set by hashicorp/terraform-plugin-sdk.
96+
// It modifies Terraform's behavior to work with the legacy
97+
// expectations of that SDK.
98+
//
99+
// Nobody else should use this. Ever. For any reason. Just don't do it.
100+
//
101+
// We have to expose it here for terraform-plugin-sdk to be muxable, or
102+
// we wouldn't even be including it in this type. Don't use it. It may
103+
// go away or change behavior on you with no warning. It is
104+
// explicitly unsupported and not part of our SemVer guarantees.
105+
//
106+
// Deprecated: Really, just don't use this, you don't need it.
107+
UnsafeToUseLegacyTypeSystem bool
80108
}
81109

82110
type ImportResourceStateRequest struct {

0 commit comments

Comments
 (0)