Skip to content

Commit cb1f813

Browse files
committed
Add godoc comment to NullifyWriteOnlyAttributes()
1 parent 44d4a25 commit cb1f813

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

internal/fwserver/write_only_nullification.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ import (
1515
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
1616
)
1717

18+
// NullifyWriteOnlyAttributes transforms a tftypes.Value, setting all write-only attribute values
19+
// to null according to the given managed resource schema. This function is called in all managed
20+
// resource RPCs before a response is sent to Terraform Core. Terraform Core expects all write-only
21+
// attribute values to be null to prevent data consistency errors. This can technically be done
22+
// manually by the provider developers, but the Framework is handling it instead for convenience.
1823
func NullifyWriteOnlyAttributes(ctx context.Context, resourceSchema fwschema.Schema) func(*tftypes.AttributePath, tftypes.Value) (tftypes.Value, error) {
1924
return func(path *tftypes.AttributePath, val tftypes.Value) (tftypes.Value, error) {
2025
ctx = logging.FrameworkWithAttributePath(ctx, path.String())
@@ -51,7 +56,7 @@ func NullifyWriteOnlyAttributes(ctx context.Context, resourceSchema fwschema.Sch
5156
}
5257

5358
// Value type from new state to create null with
54-
newValueType := val.Type()
59+
newValueType := attribute.GetType().TerraformType(ctx)
5560

5661
// If the attribute is dynamic set the new value type to DynamicPseudoType
5762
// instead of the underlying concrete type

0 commit comments

Comments
 (0)