Skip to content

Commit c76bfd5

Browse files
committed
update plugin-go to use ValueType method
1 parent a5a8d6a commit c76bfd5

File tree

3 files changed

+9
-48
lines changed

3 files changed

+9
-48
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/hashicorp/logutils v1.0.0
1616
github.com/hashicorp/terraform-exec v0.22.0
1717
github.com/hashicorp/terraform-json v0.24.1-0.20250314103308-f86d5e36f4ab
18-
github.com/hashicorp/terraform-plugin-go v0.27.0-alpha.1
18+
github.com/hashicorp/terraform-plugin-go v0.27.0-alpha.1.0.20250325210248-fa8d1fe4306b
1919
github.com/hashicorp/terraform-plugin-log v0.9.0
2020
github.com/hashicorp/terraform-plugin-sdk/v2 v2.36.1
2121
github.com/mitchellh/go-testing-interface v1.14.1
@@ -58,5 +58,5 @@ require (
5858
google.golang.org/appengine v1.6.8 // indirect
5959
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
6060
google.golang.org/grpc v1.71.0 // indirect
61-
google.golang.org/protobuf v1.36.5 // indirect
61+
google.golang.org/protobuf v1.36.6 // indirect
6262
)

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ github.com/hashicorp/terraform-exec v0.22.0 h1:G5+4Sz6jYZfRYUCg6eQgDsqTzkNXV+fP8
8080
github.com/hashicorp/terraform-exec v0.22.0/go.mod h1:bjVbsncaeh8jVdhttWYZuBGj21FcYw6Ia/XfHcNO7lQ=
8181
github.com/hashicorp/terraform-json v0.24.1-0.20250314103308-f86d5e36f4ab h1:5Qpuprk76zkVEdTCtfoPjUc+1AeUxlgkF6sWTr7qLDs=
8282
github.com/hashicorp/terraform-json v0.24.1-0.20250314103308-f86d5e36f4ab/go.mod h1:sMKS8fiRDX4rVlR6EJUMudg1WcanxCMoWwTLkgZP/vc=
83-
github.com/hashicorp/terraform-plugin-go v0.27.0-alpha.1 h1:/IZFNUEafGnJGXRe2iNQQ+vtzEw/5qiD+gOxkFrNbi4=
84-
github.com/hashicorp/terraform-plugin-go v0.27.0-alpha.1/go.mod h1:Tf2HngbyKvovAlGXgBOVGm3EDvbNaN/StUaTXwrej4o=
83+
github.com/hashicorp/terraform-plugin-go v0.27.0-alpha.1.0.20250325210248-fa8d1fe4306b h1:JCAO+OdLztQ6F2bZ8lU93u986UVQl2Y/HNz18/jg3b0=
84+
github.com/hashicorp/terraform-plugin-go v0.27.0-alpha.1.0.20250325210248-fa8d1fe4306b/go.mod h1:HFPb73wivXPZy5wMuE7T3WqFbpIj6R6q1svKnZsnMZo=
8585
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
8686
github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
8787
github.com/hashicorp/terraform-plugin-sdk/v2 v2.36.1 h1:WNMsTLkZf/3ydlgsuXePa3jvZFwAJhruxTxP/c1Viuw=
@@ -220,8 +220,8 @@ google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg=
220220
google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
221221
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
222222
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
223-
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
224-
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
223+
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
224+
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
225225
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
226226
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
227227
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

internal/testing/testsdk/providerserver/tftypes.go

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ func IdentityDynamicValueToValue(schema *tfprotov6.ResourceIdentitySchema, dynam
7676
}
7777

7878
if dynamicValue == nil {
79-
return tftypes.NewValue(getIdentitySchemaValueType(schema), nil), nil
79+
return tftypes.NewValue(schema.ValueType(), nil), nil
8080
}
8181

82-
value, err := dynamicValue.Unmarshal(getIdentitySchemaValueType(schema))
82+
value, err := dynamicValue.Unmarshal(schema.ValueType())
8383

8484
if err != nil {
8585
diag := &tfprotov6.Diagnostic{
@@ -105,7 +105,7 @@ func IdentityValuetoDynamicValue(schema *tfprotov6.ResourceIdentitySchema, value
105105
return nil, diag
106106
}
107107

108-
dynamicValue, err := tfprotov6.NewDynamicValue(getIdentitySchemaValueType(schema), value)
108+
dynamicValue, err := tfprotov6.NewDynamicValue(schema.ValueType(), value)
109109

110110
if err != nil {
111111
diag := &tfprotov6.Diagnostic{
@@ -119,42 +119,3 @@ func IdentityValuetoDynamicValue(schema *tfprotov6.ResourceIdentitySchema, value
119119

120120
return &dynamicValue, nil
121121
}
122-
123-
// TODO: This should be replaced by the `ValueType` method from plugin-go:
124-
// https://github.com/hashicorp/terraform-plugin-go/pull/497
125-
func getIdentitySchemaValueType(schema *tfprotov6.ResourceIdentitySchema) tftypes.Type {
126-
if schema == nil || schema.IdentityAttributes == nil {
127-
return tftypes.Object{
128-
AttributeTypes: map[string]tftypes.Type{},
129-
}
130-
}
131-
attributeTypes := map[string]tftypes.Type{}
132-
133-
for _, attribute := range schema.IdentityAttributes {
134-
if attribute == nil {
135-
continue
136-
}
137-
138-
attributeType := getIdentityAttributeValueType(attribute)
139-
140-
if attributeType == nil {
141-
continue
142-
}
143-
144-
attributeTypes[attribute.Name] = attributeType
145-
}
146-
147-
return tftypes.Object{
148-
AttributeTypes: attributeTypes,
149-
}
150-
}
151-
152-
// TODO: This should be replaced by the `ValueType` method from plugin-go:
153-
// https://github.com/hashicorp/terraform-plugin-go/pull/497
154-
func getIdentityAttributeValueType(attr *tfprotov6.ResourceIdentitySchemaAttribute) tftypes.Type {
155-
if attr == nil {
156-
return nil
157-
}
158-
159-
return attr.Type
160-
}

0 commit comments

Comments
 (0)