-
Notifications
You must be signed in to change notification settings - Fork 113
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 deep merge of ValuesYamlFiles #2963
Merged
blampe
merged 7 commits into
pulumi:master
from
KevinFairise2:kfairise/deep-merge-valuesyalm
Apr 24, 2024
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ebd496e
Fix deep merge of ValuesYamlFiles
KevinFairise2 85313c3
Update changelog
KevinFairise2 0435b26
Add a simple regression test
blampe 87b26a9
Reword changelog
blampe 7b7b645
Use upstream mergeMaps
blampe b2523ab
Test merging with literals
blampe 3ab077b
Merge branch 'master' into kfairise/deep-merge-valuesyalm
blampe File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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 notice we might still deviate from upstream's behavior here -- this is Helm's logic:
https://github.com/helm/helm/blob/14d0c13e9eefff5b4a1b511cf50643529692ec94/pkg/cli/values/options.go#L108-L125
But we're using github.com/imdario/mergo.Merge. I haven't looked at this closely enough to see if there are behavioral difference -- it's quite a bit more complex so I imagine there must be?
I would feel a lot better if we followed upstream's
mergeMaps
logic directly. It's not public but I wonder if we should just vendor the logic to stay closer to upstream. Or maybe this is an edge case not worth worrying about?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 would definitely advocate for using Helm itself as much as possible, copying as necessary.
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.
Thanks for your fast feedbacks on that PR!
Using the same function as Helm to merge the maps sounds look I good idea.
mergo.Merge
can do a deep merge on any struct, so the code is indeed way more complex. In our case we only need to deep merge twomap[string]any
so using the same function as Helm should be enough.I can replace the call to
mergo.Merge
here with a call to a copy of the Helm merge maps. If that sounds good to you. As you said it is hard to anticipate any behavior changes seeing how complex themergoM.Merge
implementation is.Do you think your tests would catch any changes in the behavior of
mergeMaps
?Let me know how I should handle License things if I copy the function from Helm. The code they use seems to be standard way to deep merge two
map[string]any
that can be found elsewhere on the internetThere 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 pushed a change to use upstream's merge logic. Both projects are Apache 2.0 and they don't include a
NOTICE
so I think it's sufficient to preserve attribution.I left the existing
mergeMaps
implementation alone because I'd like to keep the scope of this change as small as possible for now. I'm not sure how well our tests cover that behavior.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.
PR looks good to me like that. I think everything is in your hand to have it merged now. Let me know if I can do anything more to help with that.
What will be the release plan for that? I think this is a breaking change that can impact current users of the provider.
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.
It's breaking in the sense that behavior will change, yes. In this case it's a bug that this field doesn't agree (and has never agreed) with helm's behavior despite claiming to. I'm comfortable fixing the behavior instead of forcing users to live with it until a much later date for v5 -- or introducing another awkward field
valueYamlFilesThisIsTheOneYouReallyWant
.Correctness is more important since the current behavior can potentially cause cascading issues by unexpectedly dropping values. If someone has been impacted by this, they might not realize it (in which case they could be sitting on a time bomb) or they might have worked around it by providing a union of values (in which case the change in behavior is less impactful).
In any case, previews will show a diff with any impacted values and users can choose to modify their values accordingly.