Open magodo opened 7 months ago
Related feature request issue: https://github.com/hashicorp/terraform-plugin-framework/issues/597
For any reviewers, please note that the current attr.Value
interface change is a breaking change since it would force all existing custom type implementations to need to include the new method. I'm adding the GitHub label to call this out. @magodo I'm not providing a full review, but it might be good to update the proposed implementation to avoid the breaking change so it potentially can get into any release, rather than needing to wait for a future major version of the Go module. If you would like to discuss available options there, please reach out.
@bflad The other possible option I can think of is the 2nd one I mentioned above, which won't handle the custom types. I don't know how can we avoid breaking change while still taking custom types into consideration at this moment..
This new method is similar to the
Value.IsFullyKnown()
that is available in thegithub.com/hashicorp/terraform-plugin-go/tftypes
.The difference here is that in
tftypes
, each value can only has two states: a concrete value (includingnil
) or "unknown". While in the fw, each value can has three states: null, unknown and known. This is why the method name is chose so (as I can't figure out another better name, asIsFullyNotKnown
orIsPartiallyUnknown
are ambiguous than the current one, IMO).The reason for introducing this method is to allow provider developers to check the state of an aggregate value during the
ModifyPlan
, where the code might stop processing that property if its value contains any unknwon value. Currently, the developer has two solutions:ToTerraformValue()
to convert theattr.Value
totftypes.Value
, then call itsIsFullyKnown()
. This works fine (and it is also used in the FW itself somewhere), while it is a bit over kill to do the conversion where the intent is only to check the whole (un)known-ness.Self implement the
IsFullyKnown()
for theattr.Value
, similar to:This PR tries to put this common logic to the FW so that more developers can save the run/develop time effort for the same purpose. I chose to extend the
attr.Value
interface, instead of introducing a helper method in theattr
package, as a random choice. If the latter looks better, then I can rework this PR.