Extend attr.Value
interface to support IsFullyNullableKnown()
#980
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This new method is similar to the
Value.IsFullyKnown()
that is available in thegithub.1485827954.workers.dev/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:Convert the
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.