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

Perform deep merge for template values #4668

Merged
merged 4 commits into from
May 2, 2018

Conversation

gwkunze
Copy link
Contributor

@gwkunze gwkunze commented Mar 13, 2018

As per #4662 improves the merging of multiple --values arguments by doing a deep merge. This way nested maps will all be merged instead of overwriting each other.

NOTE: ⚠️ This code is copied from the kubernetes/helm project. Since this is another CNCF project I suspect this is fine, but would like confirmation.

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please sign in with your organization's credentials at https://identity.linuxfoundation.org/projects/cncf to be authorized.
  • If you have done the above and are still having issues with the CLA being reported as unsigned, please email the CNCF helpdesk: [email protected]

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Mar 13, 2018
@gwkunze
Copy link
Contributor Author

gwkunze commented Mar 13, 2018

/assign @geojaz

}
}

return context, nil
}

// Merges source and destination map, preferring values from the source map
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make a note where we used this code from? It is all OSS under the same language, so it is fine. But lets give credit.

@chrislovecnm
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 25, 2018
@chrislovecnm
Copy link
Contributor

CI is not happy. The new tests should give you some incite on what is wrong.

@chrislovecnm
Copy link
Contributor

chrislovecnm commented Mar 25, 2018

Man I love our new tests! Sorry patting myself on the back </sarcasm>. If you click on the details link in either window you will be told the commands that you need to run in order to fix the problems with the new code. Fixing the boilerplate is usually easier by just copy and pasting the header to your new file.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 26, 2018
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 26, 2018
continue
}
// If the key doesn't exist already, then just set the key to that value
if _, exists := dest[k]; !exists {
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this a duplicate of the first if?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I'll also make a PR for the Helm project

@justinsb
Copy link
Member

justinsb commented Apr 2, 2018

@gambol99 what do you think? Code looks fine, and I think the merge behaviour is more intuitive (but the intricacies of map vs non-map are also pretty tricky, even if they shouldn't happen in practice)

@justinsb justinsb assigned gambol99 and unassigned geojaz Apr 2, 2018
@justinsb justinsb added this to the 1.10 milestone Apr 2, 2018
@gambol99
Copy link
Contributor

gambol99 commented Apr 5, 2018

... looks good to me 👍

@mikesplain
Copy link
Contributor

I just ran into this and am glad to see @gwkunze already implemented the fix. Soft lgtm from me!

@justinsb
Copy link
Member

justinsb commented May 2, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels May 2, 2018
@justinsb
Copy link
Member

justinsb commented May 2, 2018

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gwkunze, justinsb

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 7ff94b6 into kubernetes:master May 2, 2018
gwkunze pushed a commit to usabilla/kops that referenced this pull request May 9, 2018
gwkunze pushed a commit to usabilla/kops that referenced this pull request May 15, 2018
mikesplain pushed a commit to mikesplain/kops that referenced this pull request Jun 29, 2018
gwkunze pushed a commit to usabilla/kops that referenced this pull request Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants