Skip to content

Commit b488bac

Browse files
authored
Remove marking of entire object as unknown when child attribute is unknown (#63)
* remove marking of unknown for nested attributes * update diag return to unknown
1 parent 08606fc commit b488bac

File tree

12 files changed

+1137
-3701
lines changed

12 files changed

+1137
-3701
lines changed

internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/datasource_example/example_data_source_gen.go

Lines changed: 219 additions & 567 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/provider_example/example_provider_gen.go

Lines changed: 77 additions & 329 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/resource_example/example_resource_gen.go

Lines changed: 77 additions & 329 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/example_data_source_gen.go

Lines changed: 219 additions & 567 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/example_provider_gen.go

Lines changed: 77 additions & 329 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/example_resource_gen.go

Lines changed: 77 additions & 329 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/cmd/testdata/custom_and_external/data_sources_output/example_data_source_gen.go

Lines changed: 219 additions & 567 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/cmd/testdata/custom_and_external/provider_output/example_provider_gen.go

Lines changed: 77 additions & 329 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/cmd/testdata/custom_and_external/resources_output/example_resource_gen.go

Lines changed: 77 additions & 329 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/schema/custom_object_test.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,6 @@ if diags.HasError() {
228228
return NewExampleValueUnknown(), diags
229229
}
230230
231-
state := attr.ValueStateKnown
232-
233231
234232
boolAttribute, ok := attributes["bool_attribute"]
235233
@@ -238,7 +236,7 @@ diags.AddError(
238236
"Attribute Missing",
239237
` + "`bool_attribute is missing from object`" + `)
240238
241-
return NewExampleValueNull(), diags
239+
return NewExampleValueUnknown(), diags
242240
}
243241
244242
boolAttributeVal, ok := boolAttribute.(basetypes.BoolValue)
@@ -249,14 +247,14 @@ diags.AddError(
249247
fmt.Sprintf(` + "`bool_attribute expected to be basetypes.BoolValue, was: %T`" + `, boolAttribute))
250248
}
251249
252-
if boolAttributeVal.IsUnknown() {
253-
state = attr.ValueStateUnknown
254-
}
255250
251+
if diags.HasError() {
252+
return NewExampleValueUnknown(), diags
253+
}
256254
257255
return ExampleValue{
258256
BoolAttribute: boolAttributeVal,
259-
state: state,
257+
state: attr.ValueStateKnown,
260258
}, diags
261259
}`),
262260
},
@@ -301,8 +299,6 @@ func TestCustomObjectType_renderValueFromObject(t *testing.T) {
301299
func (t ExampleType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
302300
var diags diag.Diagnostics
303301
304-
state := attr.ValueStateKnown
305-
306302
attributes := in.Attributes()
307303
308304
@@ -324,14 +320,14 @@ diags.AddError(
324320
fmt.Sprintf(` + "`bool_attribute expected to be basetypes.BoolValue, was: %T`" + `, boolAttribute))
325321
}
326322
327-
if boolAttributeVal.IsUnknown() {
328-
state = attr.ValueStateUnknown
329-
}
330323
324+
if diags.HasError() {
325+
return nil, diags
326+
}
331327
332328
return ExampleValue{
333329
BoolAttribute: boolAttributeVal,
334-
state: state,
330+
state: attr.ValueStateKnown,
335331
}, diags
336332
}`),
337333
},

0 commit comments

Comments
 (0)