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 a few issues with diff #100

Merged
merged 2 commits into from
Jul 25, 2023
Merged

Fix a few issues with diff #100

merged 2 commits into from
Jul 25, 2023

Conversation

lukehoban
Copy link
Contributor

@lukehoban lukehoban commented Jul 24, 2023

The diff routine has three issues:

  1. It does not correctly handle changes in nested properties
  2. It inverts adds/deletes in the diffs it reports, leading to confusing diff presentation
  3. It is untested.

This PR fixes these issues.

The first issue was introduced by the use of ignoreKeys callbacks on PropertyValue Diff. Unfortunately, that feature in pulumi/pulumi is not really safe to use, because it doesn't return full property paths, only the final key name in the nested path. So the caller cannot determine which nested key is really being referenced. The only other place it is used in pulumi/pulumi happens to only need to be correct for top-level properties, so happens to work. But it does not work for the way it was being used here.

The second issue is an inversion of the order of arguments to PropertyMap#Diff.

Test coverage for all the core of Diff is added. Additional coverage for ignoreChanges, CustomDiff, and Replacements should also be added in the future.

Fixes pulumi/pulumi-command#231.

The diff routine has three issues:
1. It does not correctly handled changes in nested proeprties
2. It inverts adds/deletes in the diffs it reports, leading to confusing diff presentation
3. It is untested.

This PR fixes these issues.

The first issue was introduced by the use of `ignoreKeys` callbacks on PropertyValue Diff.  Unfortunately, that feature in pulumi/pulumi is not really safe to use, because it doesn't return full property paths, only the final key name in the nested path.  So the caller cannot determine which nested key is really being referenced.  The only other place it is used in pulumi/pulumi happens to only need to be correct for top-level properties, so happens to work.  But it does not work for the way it was being used here.

The second issue is an inversion of the order of arguments to PropertyMap#Diff.

Test coverage for all the core of Diff is added.  Additional coverage for ignoreChanges, CustomDiff, and Replacements should also be added in the future.
@lukehoban lukehoban requested a review from iwahbe July 24, 2023 23:47
Copy link
Member

@iwahbe iwahbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I have opened #103, #101 and #102 to track future testing.

@iwahbe iwahbe merged commit 7ee5da8 into main Jul 25, 2023
@iwahbe iwahbe deleted the lukehoban/fixdiff branch July 25, 2023 15:26
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.

Diff doesn't work correctly on environment property
2 participants