terraform-plugin-framework
terraform-plugin-framework copied to clipboard
attr: Remove Requirement for tftypes Handling from Exported Type/Value Interfaces
Module version
v1.0.0
Use-cases
Provider developers should not need to drop down to the github.com/hashicorp/terraform-plugin-go/tftypes type system when creating custom types via attr.Type and attr.Value. In particular:
attr.Type
tftypes.AttributePathStepperTerraformType(context.Context) tftypes.TypeValueFromTerraform(context.Context, tftypes.Value) (Value, error)
attr.Value
ToTerraformValue(context.Context) (tftypes.Value, error)
The framework recently migrated the framework types into a types/basetypes package, which enables embedding in many cases. That package also has framework type system-specific interfaces such as StringTypable and StringValuable for describing how to convert custom framework types to/from the framework types, e.g.
basetypes.StringTypable
ValueFromString(context.Context, StringValue) (StringValuable, diag.Diagnostics)
basetypes.StringValuable
ToStringValue(ctx context.Context) (StringValue, diag.Diagnostics)
The work to remove the tftypes burden was not completed before version 1.0 though, so custom types developers are still left with this burden.
Proposal
Ideally, these details of the framework type system tftypes handling would be an internal package interface that only the types/basetypes types implement. Since version 1.0 is released though, we'll need to be careful about external usage of the existing interface methods, even if the framework internally switches to a different interface.
More thought will be needed on how to accomplish this though, as this type system conversion is fairly central to the framework's data handling.
References
- #172