From a86fe3bdc9536f1069c9f115100ba2dd18915c2f Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Mon, 31 Jan 2022 14:52:41 -0500 Subject: [PATCH 1/2] tftypes: Further document Object type OptionalAttributes field usage Reference: https://github.com/hashicorp/terraform-plugin-go/issues/82 Reference: https://github.com/hashicorp/terraform-plugin-go/issues/83 Reference: https://github.com/hashicorp/terraform-plugin-go/issues/97 Reference: https://github.com/hashicorp/terraform-plugin-go/issues/128 --- tftypes/object.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tftypes/object.go b/tftypes/object.go index 418b464f..ac577c65 100644 --- a/tftypes/object.go +++ b/tftypes/object.go @@ -24,6 +24,12 @@ type Object struct { // are considered part of the type signature, and their absence means a // value is no longer of that type. // + // OptionalAttributes is only valid when declaring a type constraint + // (e.g. Schema) and should not be used as part of a Type when creating + // a Value (e.g. NewValue()). When creating a Value, all OptionalAttributes + // must still be defined in the Object by setting each attribute to a null + // value for its attribute type. + // // The key of OptionalAttributes should be the name of the attribute // that is optional. The value should be an empty struct, used only to // indicate presence. From 1e73e4829aed33928f0c59343cffdd71c82ea3da Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Mon, 31 Jan 2022 14:56:48 -0500 Subject: [PATCH 2/2] tftypes: Clarify OptionalAttributes may be known values too --- tftypes/object.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tftypes/object.go b/tftypes/object.go index ac577c65..ef3a622b 100644 --- a/tftypes/object.go +++ b/tftypes/object.go @@ -28,7 +28,7 @@ type Object struct { // (e.g. Schema) and should not be used as part of a Type when creating // a Value (e.g. NewValue()). When creating a Value, all OptionalAttributes // must still be defined in the Object by setting each attribute to a null - // value for its attribute type. + // or known value for its attribute type. // // The key of OptionalAttributes should be the name of the attribute // that is optional. The value should be an empty struct, used only to