hashicorp / terraform-plugin-go

A low-level Go binding for the Terraform protocol for integrations to be built on top of.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consider Adding tfprotov5/tfprotov6 Schema* Methods for tftypes.Type Conversion

bflad opened this issue · comments

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.

References