attr: Consider Adding ValueType Method to Type Interface #496
Labels
enhancement
New feature or request
reflection
Issues and PRs about the reflection subsystem used to convert between attr.Values and Go values.
types
Issues and pull requests about our types abstraction and implementations.
Milestone
Module version
Use-cases
When the internal reflection package is attempting to build values or convert them into given types, it needs to raise errors when the given target type/value is incompatible. Today, these errors can tell provider developers what went wrong, but not necessarily offer help for how to resolve it.
An example diagnostic that we'd like to raise:
Attempted Solutions
It's technically possible to try to get the associated
attr.Value
of anattr.Type
by doing something like:However, supporting null values in an
attr.Type
is not a requirement, as edge case-y as that may be, since in all implementations may beRequired
in the schema.Proposal
Consider introducing a new method in the
attr.Type
interface:Or, make it optional, where the reflection package can pick it up if it is detected:
References
The text was updated successfully, but these errors were encountered: