terraform-plugin-framework icon indicating copy to clipboard operation
terraform-plugin-framework copied to clipboard

Consider Splitting tfsdk.Attribute into datasource.Attribute, provider.Attribute, and resource.Attribute

Open bflad opened this issue 4 years ago • 1 comments

Module version

Post plan modification support

Use-cases

Plan modifications can only occur on resource attributes. Since the Attribute type is shared across data source, provider, and resource schemas, it is possible to define plan modifiers on data source and provider attributes which will have no effect. This can be confusing for provider developers.

Attempted Solutions

Note behavior in Go documentation.

Proposal

Consider creating separate Go types for data source, provider, and resource attributes which can cause compile-time errors for functionality not supported by each type. e.g.

package datasource
type Attribute struct{
  // ... Type, etc. ....
}

package provider
type Attribute struct{
  // ... Type, etc. ....
}

package resource
type Attribute struct{
  // ... Type, etc. ....
  PlanModifiers []AttributePlanModifier
}

References

  • https://github.com/hashicorp/terraform-plugin-framework/pull/123/files#r702095995

bflad avatar Sep 07 '21 15:09 bflad

I am gently suspicious that the fix will make things confusing (nested attributes can accept provider attributes inside a data source attribute?) but I think it's an interesting line of inquiry.

paddycarver avatar Sep 07 '21 17:09 paddycarver

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

github-actions[bot] avatar Jan 13 '23 02:01 github-actions[bot]