schema/ExactlyOneOf: Fix handling of unknowns in complex types #287
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.
Fixes #280
I also added some more tests to check that the same bug doesn't affect
ConflictsWith
orAtLeastOneOf
- it doesn't, but it's IMO useful to have the test there to ensure it stays that way.The reason
ConflictsWith
isn't affected is because it runs after we check for unknowns:terraform-plugin-sdk/helper/schema/schema.go
Lines 1417 to 1433 in 6184b31
I decided not to move things around in the main
validate()
as there is a risk of introducing some more unknown edge cases when folks combineConflictsWith
,AtLeastOneOf
andExactlyOneOf
.Perhaps that code deserves some cleanup, but I think it's safer to leave it for later, bigger refactoring and/or for when we introduce cty here.
I guess the reason
IsComputed()
wasn't used in the initial implementation is for its confusing name.It does not to have anything to do with
Computed
in the schema, but "computed" here just means "unknown". Cty already uses that clearer naming convention of "(un)knowns", so we can adopt it here too when we switch to it from the old type system.IsComputed()
seems to be more or less equivalent of cty'sIsWhollyKnown()
as it leveragesreflectwalk
's ability to walk through the complex types and find nested unknowns there:terraform-plugin-sdk/terraform/resource.go
Lines 393 to 397 in 6184b31