Skip to content

Commit

Permalink
Upgrade terraform-plugin-go to 0.3.0 (dev)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
paddycarver committed Apr 21, 2021
1 parent 893e723 commit e42067a
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 75 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ require (
github.com/hashicorp/logutils v1.0.0
github.com/hashicorp/terraform-exec v0.13.0
github.com/hashicorp/terraform-json v0.8.0
github.com/hashicorp/terraform-plugin-go v0.2.1
github.com/hashicorp/terraform-plugin-go v0.2.2-0.20210414015844-4730a5d4579d
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba
github.com/kylelemons/godebug v1.1.0 // indirect
Expand Down
34 changes: 2 additions & 32 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions helper/schema/grpc_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/hashicorp/go-cty/cty/msgpack"

"github.com/hashicorp/terraform-plugin-go/tfprotov5"
"github.com/hashicorp/terraform-plugin-go/tfprotov5/tftypes"
"github.com/hashicorp/terraform-plugin-go/tftypes"
"github.com/hashicorp/terraform-plugin-sdk/v2/internal/configs/configschema"
"github.com/hashicorp/terraform-plugin-sdk/v2/internal/configs/hcl2shim"
"github.com/hashicorp/terraform-plugin-sdk/v2/internal/plans/objchange"
Expand Down Expand Up @@ -1155,7 +1155,7 @@ func pathToAttributePath(path cty.Path) *tftypes.AttributePath {
if len(steps) < 1 {
return nil
}
return &tftypes.AttributePath{Steps: steps}
return tftypes.NewAttributePathWithSteps(steps)
}

// helper/schema throws away timeout values from the config and stores them in
Expand Down
12 changes: 6 additions & 6 deletions internal/plugin/convert/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/hashicorp/go-cty/cty"

"github.com/hashicorp/terraform-plugin-go/tfprotov5"
"github.com/hashicorp/terraform-plugin-go/tfprotov5/tftypes"
"github.com/hashicorp/terraform-plugin-go/tftypes"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
)

Expand Down Expand Up @@ -92,7 +92,7 @@ func AttributePathToPath(ap *tftypes.AttributePath) cty.Path {
if ap == nil {
return p
}
for _, step := range ap.Steps {
for _, step := range ap.Steps() {
switch step.(type) {
case tftypes.AttributeName:
p = p.GetAttr(string(step.(tftypes.AttributeName)))
Expand All @@ -110,20 +110,20 @@ func PathToAttributePath(p cty.Path) *tftypes.AttributePath {
if p == nil || len(p) < 1 {
return nil
}
ap := &tftypes.AttributePath{}
ap := tftypes.NewAttributePath()
for _, step := range p {
switch selector := step.(type) {
case cty.GetAttrStep:
ap.Steps = append(ap.Steps, tftypes.AttributeName(selector.Name))
ap = ap.WithAttributeName(selector.Name)

case cty.IndexStep:
key := selector.Key
switch key.Type() {
case cty.String:
ap.Steps = append(ap.Steps, tftypes.ElementKeyString(key.AsString()))
ap = ap.WithElementKeyString(key.AsString())
case cty.Number:
v, _ := key.AsBigFloat().Int64()
ap.Steps = append(ap.Steps, tftypes.ElementKeyInt(v))
ap = ap.WithElementKeyInt(v)
default:
// We'll bail early if we encounter anything else, and just
// return the valid prefix.
Expand Down
53 changes: 21 additions & 32 deletions internal/plugin/convert/diagnostics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/hashicorp/go-cty/cty"

"github.com/hashicorp/terraform-plugin-go/tfprotov5"
"github.com/hashicorp/terraform-plugin-go/tfprotov5/tftypes"
"github.com/hashicorp/terraform-plugin-go/tftypes"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
)

Expand Down Expand Up @@ -139,12 +139,9 @@ func TestDiagnostics(t *testing.T) {
Severity: tfprotov5.DiagnosticSeverityError,
Summary: "error",
Detail: "error detail",
Attribute: &tftypes.AttributePath{
Steps: []tftypes.AttributePathStep{

tftypes.AttributeName("attribute_name"),
},
},
Attribute: tftypes.NewAttributePathWithSteps([]tftypes.AttributePathStep{
tftypes.AttributeName("attribute_name"),
}),
})
return diags
},
Expand All @@ -164,46 +161,38 @@ func TestDiagnostics(t *testing.T) {
Severity: tfprotov5.DiagnosticSeverityError,
Summary: "error 1",
Detail: "error 1 detail",
Attribute: &tftypes.AttributePath{
Steps: []tftypes.AttributePathStep{
tftypes.AttributeName("attr"),
},
},
Attribute: tftypes.NewAttributePathWithSteps([]tftypes.AttributePathStep{
tftypes.AttributeName("attr"),
}),
},
&tfprotov5.Diagnostic{
Severity: tfprotov5.DiagnosticSeverityError,
Summary: "error 2",
Detail: "error 2 detail",
Attribute: &tftypes.AttributePath{
Steps: []tftypes.AttributePathStep{
tftypes.AttributeName("attr"),
tftypes.AttributeName("sub"),
},
},
Attribute: tftypes.NewAttributePathWithSteps([]tftypes.AttributePathStep{
tftypes.AttributeName("attr"),
tftypes.AttributeName("sub"),
}),
},
&tfprotov5.Diagnostic{
Severity: tfprotov5.DiagnosticSeverityWarning,
Summary: "warning",
Detail: "warning detail",
Attribute: &tftypes.AttributePath{
Steps: []tftypes.AttributePathStep{
tftypes.AttributeName("attr"),
tftypes.ElementKeyInt(1),
tftypes.AttributeName("sub"),
},
},
Attribute: tftypes.NewAttributePathWithSteps([]tftypes.AttributePathStep{
tftypes.AttributeName("attr"),
tftypes.ElementKeyInt(1),
tftypes.AttributeName("sub"),
}),
},
&tfprotov5.Diagnostic{
Severity: tfprotov5.DiagnosticSeverityError,
Summary: "error 3",
Detail: "error 3 detail",
Attribute: &tftypes.AttributePath{
Steps: []tftypes.AttributePathStep{
tftypes.AttributeName("attr"),
tftypes.ElementKeyString("idx"),
tftypes.AttributeName("sub"),
},
},
Attribute: tftypes.NewAttributePathWithSteps([]tftypes.AttributePathStep{
tftypes.AttributeName("attr"),
tftypes.ElementKeyString("idx"),
tftypes.AttributeName("sub"),
}),
},
)

Expand Down
2 changes: 1 addition & 1 deletion internal/plugin/convert/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/hashicorp/go-cty/cty"
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
"github.com/hashicorp/terraform-plugin-go/tfprotov5/tftypes"
"github.com/hashicorp/terraform-plugin-go/tftypes"
"github.com/hashicorp/terraform-plugin-sdk/v2/internal/configs/configschema"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/plugin/convert/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/hashicorp/go-cty/cty"

"github.com/hashicorp/terraform-plugin-go/tfprotov5"
"github.com/hashicorp/terraform-plugin-go/tfprotov5/tftypes"
"github.com/hashicorp/terraform-plugin-go/tftypes"
"github.com/hashicorp/terraform-plugin-sdk/v2/internal/configs/configschema"
)

Expand Down

0 comments on commit e42067a

Please sign in to comment.