-
Notifications
You must be signed in to change notification settings - Fork 71
Add ignored fields to update #161
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
Add ignored fields to update #161
Conversation
|
I'm a little confused why there are all these commits in there, do you need #133? You also have a commit that has already been merged. |
72cf25b to
4efc49f
Compare
4efc49f to
fd0df01
Compare
f055e5d to
eccbede
Compare
| } | ||
| if ignored != nil { | ||
| set = set.RecursiveDifference(ignored) | ||
| // TODO: is this correct. If we don't remove from lastSet pruning might remove the fields? |
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.
After thinking about it again, this might not be required.
Pruning should remove fields from the object if they are not present in newObject and ignored.
Please confirm
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.
lastSet.Set().RecursiveDifference(ignored)
I think that has to be wrong, we're not editing "VersionedSet" in place, and also RecursiveDifference returns a new object, so that's a no-op right now.
I would assume that the lastSet has been trimmed already (during the operation that set it), but it's possible that the ignored fields have changed since that manager was written, so doing it again seem reasonable.
apelisse
left a comment
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.
I have
|
This is really starting to look good, a few things to fix and we'll be good to go! |
apelisse
left a comment
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.
Looks good!
|
Daniel, do you want to have a look at that "RecursiveDifference" code? |
fieldpath/set_test.go
Outdated
| name string | ||
| a *Set | ||
| b *Set | ||
| expect *Set |
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.
Can you add in the expectation for the regular difference? I'm actually not following how this is different?
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.
I added both differences to the test and added the test i forgot for both.
fieldpath/set.go
Outdated
| // | ||
| // Compared to a regular difference, this recursively removes | ||
| // all children from s | ||
| // that are either children or members in s2 |
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.
Can we align this comment more with the one for Difference? I'm having a hard time understanding the difference (no pun intended). Feel free to adjust both comments, the existing one isn't amazingly clear.
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.
Can you check again?
The difference is, that a Difference only respects fields that are directly specified.
So to remove a.b.c and a.b.d from s, both need to be in s2.
But RecursiveDifference behaves more like deleting a folder that contains folders. It's enough to specify a in s2 and it's members are deleted recursively, or in the case of RecursiveDifference not added to the result.
I tried a few different explanations, but none was really good. I'm open for suggestions :-/
|
Thanks, it's much clearer now. /approve (I only looked at the tests & documentation, maybe @apelisse or @jennybuckley can review the rest and lgtm) |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kwiesmueller, lavalamp The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
I had a look at the code, thanks! |
The fieldset provided to the update/apply will be excluded from any managedFields changes, but still be reflected in the actual update.
/sig api-machinery
/wg api-expression
/cc @apelisse