Skip to content

Commit e42067a

Browse files
Paddy Carverpaddycarver
authored andcommitted
Upgrade terraform-plugin-go to 0.3.0 (dev)
Upgrade terraform-plugin-go to the unreleased 0.3.0 candidate (still awaiting merge, so commit hashes won't actually match) and account for the breaking changes.
1 parent 893e723 commit e42067a

File tree

7 files changed

+34
-75
lines changed

7 files changed

+34
-75
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ require (
2727
github.com/hashicorp/logutils v1.0.0
2828
github.com/hashicorp/terraform-exec v0.13.0
2929
github.com/hashicorp/terraform-json v0.8.0
30-
github.com/hashicorp/terraform-plugin-go v0.2.1
30+
github.com/hashicorp/terraform-plugin-go v0.2.2-0.20210414015844-4730a5d4579d
3131
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
3232
github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba
3333
github.com/kylelemons/godebug v1.1.0 // indirect

go.sum

Lines changed: 2 additions & 32 deletions
Large diffs are not rendered by default.

helper/schema/grpc_provider.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/hashicorp/go-cty/cty/msgpack"
1414

1515
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
16-
"github.com/hashicorp/terraform-plugin-go/tfprotov5/tftypes"
16+
"github.com/hashicorp/terraform-plugin-go/tftypes"
1717
"github.com/hashicorp/terraform-plugin-sdk/v2/internal/configs/configschema"
1818
"github.com/hashicorp/terraform-plugin-sdk/v2/internal/configs/hcl2shim"
1919
"github.com/hashicorp/terraform-plugin-sdk/v2/internal/plans/objchange"
@@ -1155,7 +1155,7 @@ func pathToAttributePath(path cty.Path) *tftypes.AttributePath {
11551155
if len(steps) < 1 {
11561156
return nil
11571157
}
1158-
return &tftypes.AttributePath{Steps: steps}
1158+
return tftypes.NewAttributePathWithSteps(steps)
11591159
}
11601160

11611161
// helper/schema throws away timeout values from the config and stores them in

internal/plugin/convert/diagnostics.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/hashicorp/go-cty/cty"
77

88
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
9-
"github.com/hashicorp/terraform-plugin-go/tfprotov5/tftypes"
9+
"github.com/hashicorp/terraform-plugin-go/tftypes"
1010
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1111
)
1212

@@ -92,7 +92,7 @@ func AttributePathToPath(ap *tftypes.AttributePath) cty.Path {
9292
if ap == nil {
9393
return p
9494
}
95-
for _, step := range ap.Steps {
95+
for _, step := range ap.Steps() {
9696
switch step.(type) {
9797
case tftypes.AttributeName:
9898
p = p.GetAttr(string(step.(tftypes.AttributeName)))
@@ -110,20 +110,20 @@ func PathToAttributePath(p cty.Path) *tftypes.AttributePath {
110110
if p == nil || len(p) < 1 {
111111
return nil
112112
}
113-
ap := &tftypes.AttributePath{}
113+
ap := tftypes.NewAttributePath()
114114
for _, step := range p {
115115
switch selector := step.(type) {
116116
case cty.GetAttrStep:
117-
ap.Steps = append(ap.Steps, tftypes.AttributeName(selector.Name))
117+
ap = ap.WithAttributeName(selector.Name)
118118

119119
case cty.IndexStep:
120120
key := selector.Key
121121
switch key.Type() {
122122
case cty.String:
123-
ap.Steps = append(ap.Steps, tftypes.ElementKeyString(key.AsString()))
123+
ap = ap.WithElementKeyString(key.AsString())
124124
case cty.Number:
125125
v, _ := key.AsBigFloat().Int64()
126-
ap.Steps = append(ap.Steps, tftypes.ElementKeyInt(v))
126+
ap = ap.WithElementKeyInt(v)
127127
default:
128128
// We'll bail early if we encounter anything else, and just
129129
// return the valid prefix.

internal/plugin/convert/diagnostics_test.go

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/hashicorp/go-cty/cty"
88

99
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
10-
"github.com/hashicorp/terraform-plugin-go/tfprotov5/tftypes"
10+
"github.com/hashicorp/terraform-plugin-go/tftypes"
1111
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1212
)
1313

@@ -139,12 +139,9 @@ func TestDiagnostics(t *testing.T) {
139139
Severity: tfprotov5.DiagnosticSeverityError,
140140
Summary: "error",
141141
Detail: "error detail",
142-
Attribute: &tftypes.AttributePath{
143-
Steps: []tftypes.AttributePathStep{
144-
145-
tftypes.AttributeName("attribute_name"),
146-
},
147-
},
142+
Attribute: tftypes.NewAttributePathWithSteps([]tftypes.AttributePathStep{
143+
tftypes.AttributeName("attribute_name"),
144+
}),
148145
})
149146
return diags
150147
},
@@ -164,46 +161,38 @@ func TestDiagnostics(t *testing.T) {
164161
Severity: tfprotov5.DiagnosticSeverityError,
165162
Summary: "error 1",
166163
Detail: "error 1 detail",
167-
Attribute: &tftypes.AttributePath{
168-
Steps: []tftypes.AttributePathStep{
169-
tftypes.AttributeName("attr"),
170-
},
171-
},
164+
Attribute: tftypes.NewAttributePathWithSteps([]tftypes.AttributePathStep{
165+
tftypes.AttributeName("attr"),
166+
}),
172167
},
173168
&tfprotov5.Diagnostic{
174169
Severity: tfprotov5.DiagnosticSeverityError,
175170
Summary: "error 2",
176171
Detail: "error 2 detail",
177-
Attribute: &tftypes.AttributePath{
178-
Steps: []tftypes.AttributePathStep{
179-
tftypes.AttributeName("attr"),
180-
tftypes.AttributeName("sub"),
181-
},
182-
},
172+
Attribute: tftypes.NewAttributePathWithSteps([]tftypes.AttributePathStep{
173+
tftypes.AttributeName("attr"),
174+
tftypes.AttributeName("sub"),
175+
}),
183176
},
184177
&tfprotov5.Diagnostic{
185178
Severity: tfprotov5.DiagnosticSeverityWarning,
186179
Summary: "warning",
187180
Detail: "warning detail",
188-
Attribute: &tftypes.AttributePath{
189-
Steps: []tftypes.AttributePathStep{
190-
tftypes.AttributeName("attr"),
191-
tftypes.ElementKeyInt(1),
192-
tftypes.AttributeName("sub"),
193-
},
194-
},
181+
Attribute: tftypes.NewAttributePathWithSteps([]tftypes.AttributePathStep{
182+
tftypes.AttributeName("attr"),
183+
tftypes.ElementKeyInt(1),
184+
tftypes.AttributeName("sub"),
185+
}),
195186
},
196187
&tfprotov5.Diagnostic{
197188
Severity: tfprotov5.DiagnosticSeverityError,
198189
Summary: "error 3",
199190
Detail: "error 3 detail",
200-
Attribute: &tftypes.AttributePath{
201-
Steps: []tftypes.AttributePathStep{
202-
tftypes.AttributeName("attr"),
203-
tftypes.ElementKeyString("idx"),
204-
tftypes.AttributeName("sub"),
205-
},
206-
},
191+
Attribute: tftypes.NewAttributePathWithSteps([]tftypes.AttributePathStep{
192+
tftypes.AttributeName("attr"),
193+
tftypes.ElementKeyString("idx"),
194+
tftypes.AttributeName("sub"),
195+
}),
207196
},
208197
)
209198

internal/plugin/convert/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
"github.com/hashicorp/go-cty/cty"
1010
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
11-
"github.com/hashicorp/terraform-plugin-go/tfprotov5/tftypes"
11+
"github.com/hashicorp/terraform-plugin-go/tftypes"
1212
"github.com/hashicorp/terraform-plugin-sdk/v2/internal/configs/configschema"
1313
)
1414

internal/plugin/convert/schema_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/hashicorp/go-cty/cty"
99

1010
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
11-
"github.com/hashicorp/terraform-plugin-go/tfprotov5/tftypes"
11+
"github.com/hashicorp/terraform-plugin-go/tftypes"
1212
"github.com/hashicorp/terraform-plugin-sdk/v2/internal/configs/configschema"
1313
)
1414

0 commit comments

Comments
 (0)