Skip to content

Commit b2d165b

Browse files
committed
Remove dynamic type conditional from write_only_nullification.go
1 parent cd9f942 commit b2d165b

File tree

2 files changed

+16
-30
lines changed

2 files changed

+16
-30
lines changed

internal/fwserver/write_only_nullification.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212

1313
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
1414
"github.com/hashicorp/terraform-plugin-framework/internal/logging"
15-
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
1615
)
1716

1817
// NullifyWriteOnlyAttributes transforms a tftypes.Value, setting all write-only attribute values
@@ -58,14 +57,6 @@ func NullifyWriteOnlyAttributes(ctx context.Context, resourceSchema fwschema.Sch
5857
// Value type from new state to create null with
5958
newValueType := attribute.GetType().TerraformType(ctx)
6059

61-
// If the attribute is dynamic set the new value type to DynamicPseudoType
62-
// instead of the underlying concrete type
63-
// TODO: verify if this is the correct behavior once Terraform Core implementation is complete
64-
_, isDynamic := attribute.GetType().(basetypes.DynamicTypable)
65-
if isDynamic {
66-
newValueType = tftypes.DynamicPseudoType
67-
}
68-
6960
if attribute.IsWriteOnly() && !val.IsNull() {
7061
logging.FrameworkDebug(ctx, "Nullifying write-only attribute in the newState")
7162

internal/fwserver/write_only_nullification_test.go

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ func TestNullifyWriteOnlyAttributes(t *testing.T) {
3939
"dynamic-nil": schema.DynamicAttribute{
4040
Optional: true,
4141
},
42-
"dynamic-underlying-string-nil-computed": schema.DynamicAttribute{
43-
WriteOnly: true,
44-
},
4542
"dynamic-nil-write-only": schema.DynamicAttribute{
4643
Optional: true,
4744
WriteOnly: true,
@@ -131,15 +128,14 @@ func TestNullifyWriteOnlyAttributes(t *testing.T) {
131128
},
132129
}
133130
input := tftypes.NewValue(s.Type().TerraformType(context.Background()), map[string]tftypes.Value{
134-
"string-value": tftypes.NewValue(tftypes.String, "hello, world"),
135-
"string-nil": tftypes.NewValue(tftypes.String, nil),
136-
"string-nil-write-only": tftypes.NewValue(tftypes.String, nil),
137-
"string-value-write-only": tftypes.NewValue(tftypes.String, "hello, world"),
138-
"dynamic-value": tftypes.NewValue(tftypes.String, "hello, world"),
139-
"dynamic-nil": tftypes.NewValue(tftypes.DynamicPseudoType, nil),
140-
"dynamic-underlying-string-nil-computed": tftypes.NewValue(tftypes.String, nil),
141-
"dynamic-nil-write-only": tftypes.NewValue(tftypes.DynamicPseudoType, nil),
142-
"dynamic-value-write-only": tftypes.NewValue(tftypes.String, "hello, world"),
131+
"string-value": tftypes.NewValue(tftypes.String, "hello, world"),
132+
"string-nil": tftypes.NewValue(tftypes.String, nil),
133+
"string-nil-write-only": tftypes.NewValue(tftypes.String, nil),
134+
"string-value-write-only": tftypes.NewValue(tftypes.String, "hello, world"),
135+
"dynamic-value": tftypes.NewValue(tftypes.String, "hello, world"),
136+
"dynamic-nil": tftypes.NewValue(tftypes.DynamicPseudoType, nil),
137+
"dynamic-nil-write-only": tftypes.NewValue(tftypes.DynamicPseudoType, nil),
138+
"dynamic-value-write-only": tftypes.NewValue(tftypes.String, "hello, world"),
143139
"dynamic-value-with-underlying-list-write-only": tftypes.NewValue(
144140
tftypes.List{
145141
ElementType: tftypes.Bool,
@@ -207,15 +203,14 @@ func TestNullifyWriteOnlyAttributes(t *testing.T) {
207203
}),
208204
})
209205
expected := tftypes.NewValue(s.Type().TerraformType(context.Background()), map[string]tftypes.Value{
210-
"string-value": tftypes.NewValue(tftypes.String, "hello, world"),
211-
"string-nil": tftypes.NewValue(tftypes.String, nil),
212-
"string-nil-write-only": tftypes.NewValue(tftypes.String, nil),
213-
"string-value-write-only": tftypes.NewValue(tftypes.String, nil),
214-
"dynamic-value": tftypes.NewValue(tftypes.String, "hello, world"),
215-
"dynamic-nil": tftypes.NewValue(tftypes.DynamicPseudoType, nil),
216-
"dynamic-underlying-string-nil-computed": tftypes.NewValue(tftypes.DynamicPseudoType, nil),
217-
"dynamic-nil-write-only": tftypes.NewValue(tftypes.DynamicPseudoType, nil),
218-
"dynamic-value-write-only": tftypes.NewValue(tftypes.DynamicPseudoType, nil),
206+
"string-value": tftypes.NewValue(tftypes.String, "hello, world"),
207+
"string-nil": tftypes.NewValue(tftypes.String, nil),
208+
"string-nil-write-only": tftypes.NewValue(tftypes.String, nil),
209+
"string-value-write-only": tftypes.NewValue(tftypes.String, nil),
210+
"dynamic-value": tftypes.NewValue(tftypes.String, "hello, world"),
211+
"dynamic-nil": tftypes.NewValue(tftypes.DynamicPseudoType, nil),
212+
"dynamic-nil-write-only": tftypes.NewValue(tftypes.DynamicPseudoType, nil),
213+
"dynamic-value-write-only": tftypes.NewValue(tftypes.DynamicPseudoType, nil),
219214
"dynamic-value-with-underlying-list-write-only": tftypes.NewValue(tftypes.DynamicPseudoType, nil),
220215
"object-nil-write-only": tftypes.NewValue(tftypes.Object{
221216
AttributeTypes: map[string]tftypes.Type{

0 commit comments

Comments
 (0)