-
Notifications
You must be signed in to change notification settings - Fork 44
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
Use non-computed property value comparison for matching detailed diff set inputs to plan #2761
Conversation
This change is part of the following stack: Change managed by git-spice. |
bc6bef7
to
7da1aec
Compare
8aec9c1
to
1213503
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2761 +/- ##
==========================================
- Coverage 68.72% 68.69% -0.03%
==========================================
Files 322 322
Lines 41340 41422 +82
==========================================
+ Hits 28411 28455 +44
- Misses 11333 11365 +32
- Partials 1596 1602 +6 ☔ View full report in Codecov by Sentry. |
7da1aec
to
dbcd3ad
Compare
1213503
to
b9a8bfe
Compare
dbcd3ad
to
12baad1
Compare
b9a8bfe
to
c1e348f
Compare
12baad1
to
0d4b52a
Compare
c1e348f
to
5527f63
Compare
0d4b52a
to
220bad9
Compare
5527f63
to
ed75d48
Compare
...tests/testdata/TestDetailedDiffSet/block_with_computed_and_nested_force_new/added_end.golden
Show resolved
Hide resolved
220bad9
to
9ed2faa
Compare
1199cc2
to
4dc519b
Compare
1b16b10
to
689dea2
Compare
935d14a
to
2b96b6b
Compare
689dea2
to
70fb526
Compare
2b96b6b
to
7b8db7c
Compare
70fb526
to
d32594b
Compare
11533f0
to
d4a1312
Compare
2c2666e
to
cae9e4f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some last comments but this is generally LGTM!
… set inputs to plan
bc31087
to
d36172e
Compare
This PR has been shipped in release v3.99.0. |
This PR reworks the way we compute the detailed diff for set type elements in order to handle sets with computed properties better.
Context
There are two reasons it is challenging to produce the detailed diff for set type properties:
OldState
andNewInputs
.These two reasons means that once we compute the detailed diff in terms of
OldState
toPlannedState
, we need to do a bit of work to transform it into a diff in terms ofOldState
andNewInputs
. MatchingPlannedState
values toNewInputs
values is especially challenging for elements which containComputed
properties as these can change during the planning process. The previous implementation used the hashes of set elements to do the matching but that completely failed for set elements withComputed
properties, as theComputed
property will change the hash.New implementation
This implementation instead uses a technique borrowed from opentofu, which is used for a similar purpose. We now do a fuzzy match on the
PlannedState
value to theNewInputs
value, which allows for differences inComputed
properties. Non-Computed
properties still need to match exactly.Example
For the schema
and the inputs
[{bar: val1}, {bar: val2}]
changing to
[{bar: val1}, {bar: val3}]
we might observe the plan becoming
[{bar: val3, baz: comp3}, {bar: val1, baz: comp1}]
We now need to correctly match the elements to their corresponding inputs, in order to correctly communicate the diff to the engine in terms of
OldState
andNewInput
:{bar: val3, baz: comp3}
should match{bar: val3}
(the second element in the input)and
{bar: val1, baz: comp1
} should match{bar: val1}
Testing
I've added additional integration tests around
Computed
in #2740 as well as unit tests here. I'll annotate any left-over issues in the recorded tests to be resolved.Changes up to 4ba30d9 have the code changes and 4ba30d9 has the test recordings.
Release
Note that this is feature flagged behind Accurate Previews
fixes #2652
fixes #2528