Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for TypeSet applying with unexpected empty element #2

Merged
merged 2 commits into from
Aug 26, 2022
Merged

Conversation

prashantv
Copy link
Collaborator

@prashantv prashantv commented Aug 26, 2022

hashicorp/terraform-plugin-sdk#895

When calculating a diff, sets are added as delete of all old attributes
and a create of all new attributes. When DiffSuppressFunc is used, the
delete attribute drops the NewRemoved field, which results in sending
a diff that ends up creating a new empty set element.

Without the fix, the test fails:

=== RUN   TestSchemaMap_Diff/30-Set_with_DiffSuppressFunc
    schema_test.go:3188: expected:
        *terraform.InstanceDiff{ [...]"rule.80.duration":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:false, NewRemoved:true, [...]

        got:
        *terraform.InstanceDiff{ [...]"rule.80.duration":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:false, [...] NewRemoved:false, [...]

Previously, NewRemoved was set to false for the sustain field even though it belonged to an element being removed.

hashicorp/terraform-plugin-sdk#895

When calculating a diff, sets are added as delete of all old attributes
and a create of all new attributes. When DiffSuppressFunc is used, the
delete attribute drops the `NewRemoved` field, which results in sending
a diff that ends up creating a new empty set element.
@prashantv prashantv merged commit c747872 into main Aug 26, 2022
@prashantv prashantv deleted the set-fix branch August 26, 2022 19:07
@prashantv
Copy link
Collaborator Author

Upstream PR: hashicorp/terraform-plugin-sdk#1042

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