Skip to content

Commit b868035

Browse files
committed
types: Deprecate Null, Unknown, and Value fields
Reference: #447 When the framework type system was originally being developed, the value types were introduced with exported fields which also served as the internal details of whether a value was null, unknown, or a known value of a friendlier Go type. It was known that there was the potential for issues, but the simplified developer experience seemed to outweigh the potential for developer issues. Fast forward a few months, this decision appears to have two consequences that the framework maintainers hear about across various forums. One issue is that the value types directly expose their internal implementation details and support the three states of a Terraform type value: being null, unknown, or a known value. Only one state should ever be set, but provider developers can make a value that is any combination of those states. This makes the framework behavior potentially indeterminate from the provider developer perspective whether, for example, a null AND unknown value becomes null OR unknown as it works its way through the framework. ```go type ThingResourceModel struct{ Computed types.String `tfsdk:"computed"` } func (r ThingResource) Create(ctx context.Context, req resource.CreateResource, resp *resource.CreateResponse) { var data ThingResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) tflog.Trace(ctx, "Data Values", map[string]any{ // Unknown value: types.String{Null: false, Unknown: true, Value: ""} "computed": plan.Computed, }) // Maybe some external API responses here, but showing hardcoded updates for // brevity. This will make the value invalid by enabling Null without // disabling Unknown. data.Computed.Null = true tflog.Trace(ctx, "Data Values", map[string]any{ // Invalid value: types.String{Null: true, Unknown: true, Value: ""} "computed": data.Computed, }) // The invalid value will be either null or unknown, depending on the // type implementation. If unknown, Terraform will error, since unknown // values are never allowed in state. resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } ``` Another issue is that the default (zero-value) state for an "unset" value type turns into a known value, which is confusing since these values explicitly support being null. This causes Terraform errors which would surface to practitioners (especially when untested) that provider developers then have to troubleshoot the error message containing Terraform's type system details, potentially discover the reason why it is happening by looking at the framework type source code, then figure out a workable solution. It's not intuitive. ```go type ThingResourceModel struct{ // let's assume this is left unconfigured (null in config and plan) Optional types.String `tfsdk:"optional"` } func (r ThingResource) Create(ctx context.Context, req resource.CreateResource, resp *resource.CreateResponse) { // Providers can opt to use a single variable that is updated based on an // external response, however that logic can be more difficult sometimes, // so it can be easier to split them. Showing the split way to exemplify // the "unset" problem. var plan, state ThingResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) tflog.Trace(ctx, "Plan Values", map[string]any{ // Null value: types.String{Null: true, Unknown: false, Value: ""} "optional": plan.Optional, }) // Maybe some external API responses here, but intentionally not // doing any state.Optional setting, which might happen if the // external response for that data was null for example. tflog.Trace(ctx, "State Values", map[string]any{ // Zero-value: types.String{Null: false, Unknown: false, Value: ""} "optional": state.Optional, }) // The state zero-value will later cause Terraform to error, such as: // Error: Provider produced inconsistent result after apply // ... expected cty.NullVal(cty.String), got cty.StringVal("") // Since the plan value said it would be null. resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) } ``` This deprecation of the fields in preference of functions and methods aims to unexport the internal details and treat the value types as immutable once they are created. When provider developers switch over to the new model, any errant changes to the deprecated exported fields will have no effect. A future version will remove the exported fields entirely and switch the zero-value implementation of these values to being null, instead of a known zero-value of the underlying type.
1 parent 2be6665 commit b868035

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3314
-534
lines changed

.changelog/pending.txt

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
```release-note:note
2+
types: The `Bool` type `Null`, `Unknown`, and `Value` fields have been deprecated in preference of the `BoolNull()`, `BoolUnknown()`, and `BoolValue()` creation functions and `IsNull()`, `IsUnknown()`, and `ValueBool()` methods. The fields will be removed in a future release.
3+
```
4+
5+
```release-note:note
6+
types: The `Float64` type `Null`, `Unknown`, and `Value` fields have been deprecated in preference of the `Float64Null()`, `Float64Unknown()`, and `Float64Value()` creation functions and `IsNull()`, `IsUnknown()`, and `ValueFloat64()` methods. The fields will be removed in a future release.
7+
```
8+
9+
```release-note:note
10+
types: The `Int64` type `Null`, `Unknown`, and `Value` fields have been deprecated in preference of the `Int64Null()`, `Int64Unknown()`, and `Int64Value()` creation functions and `IsNull()`, `IsUnknown()`, and `ValueInt64()` methods. The fields will be removed in a future release.
11+
```
12+
13+
```release-note:note
14+
types: The `Number` type `Null`, `Unknown`, and `Value` fields have been deprecated in preference of the `NumberNull()`, `NumberUnknown()`, and `NumberValue()` creation functions and `IsNull()`, `IsUnknown()`, and `ValueBigFloat()` methods. The fields will be removed in a future release.
15+
```
16+
17+
```release-note:note
18+
types: The `String` type `Null`, `Unknown`, and `Value` fields have been deprecated in preference of the `StringNull()`, `StringUnknown()`, and `StringValue()` creation functions and `IsNull()`, `IsUnknown()`, and `ValueString()` methods. The fields will be removed in a future release.
19+
```
20+
21+
```release-note:enhancement
22+
types: Added `BoolNull()`, `BoolUnknown()`, `BoolValue()` functions, which create immutable `Bool` values
23+
```
24+
25+
```release-note:enhancement
26+
types: Added `Float64Null()`, `Float64Unknown()`, `Float64Value()` functions, which create immutable `Float64` values
27+
```
28+
29+
```release-note:enhancement
30+
types: Added `Int64Null()`, `Int64Unknown()`, `Int64Value()` functions, which create immutable `Int64` values
31+
```
32+
33+
```release-note:enhancement
34+
types: Added `NumberNull()`, `NumberUnknown()`, `NumberValue()` functions, which create immutable `Number` values
35+
```
36+
37+
```release-note:enhancement
38+
types: Added `StringNull()`, `StringUnknown()`, `StringValue()` functions, which create immutable `String` values
39+
```
40+
41+
```release-note:enhancement
42+
types: Added `Bool` type `ValueBool()` method, which returns the `bool` of the known value or `false` if null or unknown
43+
```
44+
45+
```release-note:enhancement
46+
types: Added `Float64` type `ValueFloat64()` method, which returns the `float64` of the known value or `0.0` if null or unknown
47+
```
48+
49+
```release-note:enhancement
50+
types: Added `Int64` type `ValueInt64()` method, which returns the `int64` of the known value or `0` if null or unknown
51+
```
52+
53+
```release-note:enhancement
54+
types: Added `Number` type `ValueBigFloat()` method, which returns the `*big.Float` of the known value or `nil` if null or unknown
55+
```
56+
57+
```release-note:enhancement
58+
types: Added `String` type `ValueString()` method, which returns the `string` of the known value or `""` if null or unknown
59+
```

internal/fwserver/attribute_plan_modification_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func TestAttributeModifyPlan(t *testing.T) {
6565
AttributeState: types.String{Value: "TESTATTRONE"},
6666
},
6767
expectedResp: ModifyAttributePlanResponse{
68-
AttributePlan: types.String{Value: "MODIFIED_TWO"},
68+
AttributePlan: types.StringValue("MODIFIED_TWO"),
6969
Private: testEmptyProviderData,
7070
},
7171
},
@@ -704,7 +704,7 @@ func TestAttributeModifyPlan(t *testing.T) {
704704
},
705705
},
706706
expectedResp: ModifyAttributePlanResponse{
707-
AttributePlan: types.String{Value: "TESTATTRTWO"},
707+
AttributePlan: types.StringValue("TESTATTRTWO"),
708708
RequiresReplace: path.Paths{
709709
path.Root("test"),
710710
},

internal/fwserver/block_plan_modification_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1741,7 +1741,7 @@ func TestBlockModifyPlan(t *testing.T) {
17411741
"nested_attr": types.StringType,
17421742
},
17431743
Attrs: map[string]attr.Value{
1744-
"nested_attr": types.String{Value: "MODIFIED_TWO"},
1744+
"nested_attr": types.StringValue("MODIFIED_TWO"),
17451745
},
17461746
},
17471747
},
@@ -1836,7 +1836,7 @@ func TestBlockModifyPlan(t *testing.T) {
18361836
"nested_attr": types.StringType,
18371837
},
18381838
Attrs: map[string]attr.Value{
1839-
"nested_attr": types.String{Value: "TESTATTRTWO"},
1839+
"nested_attr": types.StringValue("TESTATTRTWO"),
18401840
},
18411841
},
18421842
},

internal/fwserver/server_applyresourcechange_test.go

+18-18
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ func TestServerApplyResourceChange(t *testing.T) {
138138

139139
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
140140

141-
if data.TestRequired.Value != "test-config-value" {
142-
resp.Diagnostics.AddError("unexpected req.Config value: %s", data.TestRequired.Value)
141+
if data.TestRequired.ValueString() != "test-config-value" {
142+
resp.Diagnostics.AddError("unexpected req.Config value: %s", data.TestRequired.ValueString())
143143
}
144144

145145
// Prevent missing resource state error diagnostic
@@ -184,8 +184,8 @@ func TestServerApplyResourceChange(t *testing.T) {
184184

185185
resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
186186

187-
if data.TestRequired.Value != "test-plannedstate-value" {
188-
resp.Diagnostics.AddError("unexpected req.Plan value: %s", data.TestRequired.Value)
187+
if data.TestRequired.ValueString() != "test-plannedstate-value" {
188+
resp.Diagnostics.AddError("unexpected req.Plan value: %s", data.TestRequired.ValueString())
189189
}
190190

191191
// Prevent missing resource state error diagnostic
@@ -229,8 +229,8 @@ func TestServerApplyResourceChange(t *testing.T) {
229229

230230
resp.Diagnostics.Append(req.ProviderMeta.Get(ctx, &metadata)...)
231231

232-
if metadata.TestProviderMetaAttribute.Value != "test-provider-meta-value" {
233-
resp.Diagnostics.AddError("Unexpected req.ProviderMeta Value", "Got: "+metadata.TestProviderMetaAttribute.Value)
232+
if metadata.TestProviderMetaAttribute.ValueString() != "test-provider-meta-value" {
233+
resp.Diagnostics.AddError("Unexpected req.ProviderMeta Value", "Got: "+metadata.TestProviderMetaAttribute.ValueString())
234234
}
235235

236236
// Prevent missing resource state error diagnostic
@@ -451,8 +451,8 @@ func TestServerApplyResourceChange(t *testing.T) {
451451

452452
resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
453453

454-
if data.TestRequired.Value != "test-priorstate-value" {
455-
resp.Diagnostics.AddError("unexpected req.State value: %s", data.TestRequired.Value)
454+
if data.TestRequired.ValueString() != "test-priorstate-value" {
455+
resp.Diagnostics.AddError("unexpected req.State value: %s", data.TestRequired.ValueString())
456456
}
457457
},
458458
UpdateMethod: func(_ context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) {
@@ -487,8 +487,8 @@ func TestServerApplyResourceChange(t *testing.T) {
487487

488488
resp.Diagnostics.Append(req.ProviderMeta.Get(ctx, &data)...)
489489

490-
if data.TestProviderMetaAttribute.Value != "test-provider-meta-value" {
491-
resp.Diagnostics.AddError("unexpected req.ProviderMeta value: %s", data.TestProviderMetaAttribute.Value)
490+
if data.TestProviderMetaAttribute.ValueString() != "test-provider-meta-value" {
491+
resp.Diagnostics.AddError("unexpected req.ProviderMeta value: %s", data.TestProviderMetaAttribute.ValueString())
492492
}
493493
},
494494
UpdateMethod: func(_ context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) {
@@ -699,8 +699,8 @@ func TestServerApplyResourceChange(t *testing.T) {
699699

700700
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
701701

702-
if data.TestRequired.Value != "test-new-value" {
703-
resp.Diagnostics.AddError("Unexpected req.Config Value", "Got: "+data.TestRequired.Value)
702+
if data.TestRequired.ValueString() != "test-new-value" {
703+
resp.Diagnostics.AddError("Unexpected req.Config Value", "Got: "+data.TestRequired.ValueString())
704704
}
705705
},
706706
},
@@ -756,8 +756,8 @@ func TestServerApplyResourceChange(t *testing.T) {
756756

757757
resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
758758

759-
if data.TestComputed.Value != "test-plannedstate-value" {
760-
resp.Diagnostics.AddError("Unexpected req.Plan Value", "Got: "+data.TestComputed.Value)
759+
if data.TestComputed.ValueString() != "test-plannedstate-value" {
760+
resp.Diagnostics.AddError("Unexpected req.Plan Value", "Got: "+data.TestComputed.ValueString())
761761
}
762762
},
763763
},
@@ -813,8 +813,8 @@ func TestServerApplyResourceChange(t *testing.T) {
813813

814814
resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
815815

816-
if data.TestRequired.Value != "test-old-value" {
817-
resp.Diagnostics.AddError("Unexpected req.State Value", "Got: "+data.TestRequired.Value)
816+
if data.TestRequired.ValueString() != "test-old-value" {
817+
resp.Diagnostics.AddError("Unexpected req.State Value", "Got: "+data.TestRequired.ValueString())
818818
}
819819
},
820820
},
@@ -871,8 +871,8 @@ func TestServerApplyResourceChange(t *testing.T) {
871871

872872
resp.Diagnostics.Append(req.ProviderMeta.Get(ctx, &data)...)
873873

874-
if data.TestProviderMetaAttribute.Value != "test-provider-meta-value" {
875-
resp.Diagnostics.AddError("Unexpected req.ProviderMeta Value", "Got: "+data.TestProviderMetaAttribute.Value)
874+
if data.TestProviderMetaAttribute.ValueString() != "test-provider-meta-value" {
875+
resp.Diagnostics.AddError("Unexpected req.ProviderMeta Value", "Got: "+data.TestProviderMetaAttribute.ValueString())
876876
}
877877
},
878878
},

internal/fwserver/server_configureprovider_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ func TestServerConfigureProvider(t *testing.T) {
6868
return
6969
}
7070

71-
if got.Value != "test-value" {
72-
resp.Diagnostics.AddError("Incorrect req.Config", "expected test-value, got "+got.Value)
71+
if got.ValueString() != "test-value" {
72+
resp.Diagnostics.AddError("Incorrect req.Config", "expected test-value, got "+got.ValueString())
7373
}
7474
},
7575
},

internal/fwserver/server_createresource_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ func TestServerCreateResource(t *testing.T) {
114114

115115
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
116116

117-
if data.TestRequired.Value != "test-config-value" {
118-
resp.Diagnostics.AddError("Unexpected req.Config Value", "Got: "+data.TestRequired.Value)
117+
if data.TestRequired.ValueString() != "test-config-value" {
118+
resp.Diagnostics.AddError("Unexpected req.Config Value", "Got: "+data.TestRequired.ValueString())
119119
}
120120

121121
// Prevent missing resource state error diagnostic
@@ -153,8 +153,8 @@ func TestServerCreateResource(t *testing.T) {
153153

154154
resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
155155

156-
if data.TestRequired.Value != "test-plannedstate-value" {
157-
resp.Diagnostics.AddError("Unexpected req.Plan Value", "Got: "+data.TestRequired.Value)
156+
if data.TestRequired.ValueString() != "test-plannedstate-value" {
157+
resp.Diagnostics.AddError("Unexpected req.Plan Value", "Got: "+data.TestRequired.ValueString())
158158
}
159159

160160
// Prevent missing resource state error diagnostic
@@ -192,8 +192,8 @@ func TestServerCreateResource(t *testing.T) {
192192

193193
resp.Diagnostics.Append(req.ProviderMeta.Get(ctx, &metadata)...)
194194

195-
if metadata.TestProviderMetaAttribute.Value != "test-provider-meta-value" {
196-
resp.Diagnostics.AddError("Unexpected req.ProviderMeta Value", "Got: "+metadata.TestProviderMetaAttribute.Value)
195+
if metadata.TestProviderMetaAttribute.ValueString() != "test-provider-meta-value" {
196+
resp.Diagnostics.AddError("Unexpected req.ProviderMeta Value", "Got: "+metadata.TestProviderMetaAttribute.ValueString())
197197
}
198198

199199
// Prevent missing resource state error diagnostic

internal/fwserver/server_deleteresource_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ func TestServerDeleteResource(t *testing.T) {
109109

110110
resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
111111

112-
if data.TestRequired.Value != "test-priorstate-value" {
113-
resp.Diagnostics.AddError("unexpected req.State value: %s", data.TestRequired.Value)
112+
if data.TestRequired.ValueString() != "test-priorstate-value" {
113+
resp.Diagnostics.AddError("unexpected req.State value: %s", data.TestRequired.ValueString())
114114
}
115115
},
116116
},
@@ -138,8 +138,8 @@ func TestServerDeleteResource(t *testing.T) {
138138

139139
resp.Diagnostics.Append(req.ProviderMeta.Get(ctx, &data)...)
140140

141-
if data.TestProviderMetaAttribute.Value != "test-provider-meta-value" {
142-
resp.Diagnostics.AddError("unexpected req.ProviderMeta value: %s", data.TestProviderMetaAttribute.Value)
141+
if data.TestProviderMetaAttribute.ValueString() != "test-provider-meta-value" {
142+
resp.Diagnostics.AddError("unexpected req.ProviderMeta value: %s", data.TestProviderMetaAttribute.ValueString())
143143
}
144144
},
145145
},

internal/fwserver/server_planresourcechange_test.go

+18-18
Original file line numberDiff line numberDiff line change
@@ -810,8 +810,8 @@ func TestServerPlanResourceChange(t *testing.T) {
810810

811811
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
812812

813-
if data.TestRequired.Value != "test-config-value" {
814-
resp.Diagnostics.AddError("Unexpected req.Config Value", "Got: "+data.TestRequired.Value)
813+
if data.TestRequired.ValueString() != "test-config-value" {
814+
resp.Diagnostics.AddError("Unexpected req.Config Value", "Got: "+data.TestRequired.ValueString())
815815
}
816816
},
817817
},
@@ -902,8 +902,8 @@ func TestServerPlanResourceChange(t *testing.T) {
902902

903903
resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
904904

905-
if !data.TestComputed.Unknown {
906-
resp.Diagnostics.AddError("Unexpected req.Plan Value", "Got: "+data.TestComputed.Value)
905+
if !data.TestComputed.IsUnknown() {
906+
resp.Diagnostics.AddError("Unexpected req.Plan Value", "Got: "+data.TestComputed.ValueString())
907907
}
908908
},
909909
},
@@ -947,8 +947,8 @@ func TestServerPlanResourceChange(t *testing.T) {
947947

948948
resp.Diagnostics.Append(req.ProviderMeta.Get(ctx, &data)...)
949949

950-
if data.TestProviderMetaAttribute.Value != "test-provider-meta-value" {
951-
resp.Diagnostics.AddError("Unexpected req.ProviderMeta Value", "Got: "+data.TestProviderMetaAttribute.Value)
950+
if data.TestProviderMetaAttribute.ValueString() != "test-provider-meta-value" {
951+
resp.Diagnostics.AddError("Unexpected req.ProviderMeta Value", "Got: "+data.TestProviderMetaAttribute.ValueString())
952952
}
953953
},
954954
},
@@ -1211,8 +1211,8 @@ func TestServerPlanResourceChange(t *testing.T) {
12111211

12121212
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
12131213

1214-
if data.TestRequired.Value != "test-config-value" {
1215-
resp.Diagnostics.AddError("Unexpected req.Config Value", "Got: "+data.TestRequired.Value)
1214+
if data.TestRequired.ValueString() != "test-config-value" {
1215+
resp.Diagnostics.AddError("Unexpected req.Config Value", "Got: "+data.TestRequired.ValueString())
12161216
}
12171217
},
12181218
},
@@ -1291,8 +1291,8 @@ func TestServerPlanResourceChange(t *testing.T) {
12911291

12921292
resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
12931293

1294-
if data.TestRequired.Value != "test-state-value" {
1295-
resp.Diagnostics.AddError("Unexpected req.State Value", "Got: "+data.TestRequired.Value)
1294+
if data.TestRequired.ValueString() != "test-state-value" {
1295+
resp.Diagnostics.AddError("Unexpected req.State Value", "Got: "+data.TestRequired.ValueString())
12961296
}
12971297
},
12981298
},
@@ -1330,8 +1330,8 @@ func TestServerPlanResourceChange(t *testing.T) {
13301330

13311331
resp.Diagnostics.Append(req.ProviderMeta.Get(ctx, &data)...)
13321332

1333-
if data.TestProviderMetaAttribute.Value != "test-provider-meta-value" {
1334-
resp.Diagnostics.AddError("Unexpected req.ProviderMeta Value", "Got: "+data.TestProviderMetaAttribute.Value)
1333+
if data.TestProviderMetaAttribute.ValueString() != "test-provider-meta-value" {
1334+
resp.Diagnostics.AddError("Unexpected req.ProviderMeta Value", "Got: "+data.TestProviderMetaAttribute.ValueString())
13351335
}
13361336
},
13371337
},
@@ -1918,8 +1918,8 @@ func TestServerPlanResourceChange(t *testing.T) {
19181918

19191919
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
19201920

1921-
if data.TestRequired.Value != "test-new-value" {
1922-
resp.Diagnostics.AddError("Unexpected req.Config Value", "Got: "+data.TestRequired.Value)
1921+
if data.TestRequired.ValueString() != "test-new-value" {
1922+
resp.Diagnostics.AddError("Unexpected req.Config Value", "Got: "+data.TestRequired.ValueString())
19231923
}
19241924
},
19251925
},
@@ -1968,8 +1968,8 @@ func TestServerPlanResourceChange(t *testing.T) {
19681968

19691969
resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
19701970

1971-
if !data.TestComputed.Unknown {
1972-
resp.Diagnostics.AddError("Unexpected req.Plan Value", "Got: "+data.TestComputed.Value)
1971+
if !data.TestComputed.IsUnknown() {
1972+
resp.Diagnostics.AddError("Unexpected req.Plan Value", "Got: "+data.TestComputed.ValueString())
19731973
}
19741974
},
19751975
},
@@ -2019,8 +2019,8 @@ func TestServerPlanResourceChange(t *testing.T) {
20192019

20202020
resp.Diagnostics.Append(req.ProviderMeta.Get(ctx, &data)...)
20212021

2022-
if data.TestProviderMetaAttribute.Value != "test-provider-meta-value" {
2023-
resp.Diagnostics.AddError("Unexpected req.ProviderMeta Value", "Got: "+data.TestProviderMetaAttribute.Value)
2022+
if data.TestProviderMetaAttribute.ValueString() != "test-provider-meta-value" {
2023+
resp.Diagnostics.AddError("Unexpected req.ProviderMeta Value", "Got: "+data.TestProviderMetaAttribute.ValueString())
20242024
}
20252025
},
20262026
},

internal/fwserver/server_readdatasource_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ func TestServerReadDataSource(t *testing.T) {
9090

9191
resp.Diagnostics.Append(req.Config.Get(ctx, &config)...)
9292

93-
if config.TestRequired.Value != "test-config-value" {
94-
resp.Diagnostics.AddError("unexpected req.Config value: %s", config.TestRequired.Value)
93+
if config.TestRequired.ValueString() != "test-config-value" {
94+
resp.Diagnostics.AddError("unexpected req.Config value: %s", config.TestRequired.ValueString())
9595
}
9696
},
9797
},
@@ -116,8 +116,8 @@ func TestServerReadDataSource(t *testing.T) {
116116

117117
resp.Diagnostics.Append(req.ProviderMeta.Get(ctx, &config)...)
118118

119-
if config.TestRequired.Value != "test-config-value" {
120-
resp.Diagnostics.AddError("unexpected req.ProviderMeta value: %s", config.TestRequired.Value)
119+
if config.TestRequired.ValueString() != "test-config-value" {
120+
resp.Diagnostics.AddError("unexpected req.ProviderMeta value: %s", config.TestRequired.ValueString())
121121
}
122122
},
123123
},

0 commit comments

Comments
 (0)