Skip to content

Conversation

@boxofrad
Copy link

Description

This PR upgrades the terraform-plugin-framework dependency from v0.10.0 to v0.16.0.

There was a fairly major change to the types package in v0.16.0, in which they made the majority of values immutable, and the Value, Null, and Unknown fields unexported.

This is particularly awkward for our generated Copy*ToTerraform methods which would previously mutate the given object's attributes directly, but now need to construct new objects.

User-facing changes

Copy*ToTerraform method signature

Before:

func CopyTestToTerraform(ctx context.Context, obj *Test, tf *types.Object) diag.Diagnostics {

After:

func CopyTestToTerraform(ctx context.Context, obj *Test, curr *types.Object) (types.Object, diag.Diagnostics) {

Custom type CopyTo* method signature

Before:

func CopyToStringCustom(diags diag.Diagnostics, obj string, t attr.Type, v attr.Value) attr.Value {

After:

func CopyToStringCustom(diags diag.Diagnostics, obj string) attr.Value {

Configuration changes

The time_type and duration_type stanzas now require three new options:

  • value_from_method - the method that will be called on an attr.Value to get the value for the protobuf struct
  • value_to_method - the (package-qualified) method that will be called to construct an attr.Value from the protobuf struct value
  • null_value_method - the (package-qualified) method that will be called to construct a null attr.Value

The injected_fields stanzas now require a value_method option, which is the (package-qualified) method that will be called to construct the value of the injected field, when it is not already set.

@boxofrad boxofrad force-pushed the boxofrad/upgrade-terraform-plugin-framework branch from 5578788 to da59cf3 Compare March 14, 2025 12:10
This is a significant change because in v0.16.0, the `types` package changed
such that values are immutable and the internal state is now unexported.
@boxofrad boxofrad force-pushed the boxofrad/upgrade-terraform-plugin-framework branch from da59cf3 to ae38248 Compare March 14, 2025 12:12
f.ValueToMethod = o.ValueToMethod
f.NullValueMethod = o.NullValueMethod
f.ValueCastToType = o.CastToType
f.ValueCastFromType = o.CastFromType
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Todo for me later:

  • fix the ValueCastFromType in Override
  • write a test for the override or deprecate it?! It looks like it has been broken since forever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants