Consider Adding tfprotov5/tfprotov6 Schema* Methods for tftypes.Type Conversion
bflad opened this issue · comments
Brian Flad commented
terraform-plugin-go version
v0.7.1
Use cases
Downstream implementations, whether SDKs or providers, may need to retrieve the tftypes.Type
equivalent of tfprotov5
/tfprotov6
schema types such as:
Schema
SchemaAttribute
SchemaBlock
SchemaNestedBlock
SchemaObject
For example, this is necessary for calling (DynamicValue).Unmarshal()
, which is necessary for data handling of ApplyResourceChange
and other RPCs.
Attempted solutions
Manually (re-)implementing this logic downstream.
Proposal
Implement methods such as the following:
// package tfprotov5
func (s *Schema) Type() tftypes.Type { /* ... */ }
func (s *SchemaAttribute) Type() tftypes.Type { /* ... */ }
func (s *SchemaBlock) Type() tftypes.Type { /* ... */ }
func (s *SchemaNestedBlock) Type() tftypes.Type { /* ... */ }
// package tfprotov6
func (s *Schema) Type() tftypes.Type { /* ... */ }
func (s *SchemaAttribute) Type() tftypes.Type { /* ... */ }
func (s *SchemaBlock) Type() tftypes.Type { /* ... */ }
func (s *SchemaNestedBlock) Type() tftypes.Type { /* ... */ }
func (s *SchemaObject) Type() tftypes.Type { /* ... */ }
With associated unit testing.