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

Remove non-essential dependency imdario/mergo #5044

Merged
merged 3 commits into from Jan 31, 2024

Conversation

krzysiekg
Copy link
Contributor

This fixes #4905

There was an issue with overwriting empty values in map[string]interface{} that was fixed a while ago in darccio/mergo#84.

I'm not sure how to test it best. None of the charts used in tests have this issue. I'm thinking about replacing minecraft chart that is used to test valuesInline with istio gateway chart. That way I can test all that these tests already cover plus that empty map issue. But maybe that is too much. I can also just add a separate test just to cover this.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 10, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @krzysiekg!

It looks like this is your first PR to kubernetes-sigs/kustomize 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kustomize has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 10, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @krzysiekg. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 10, 2023
@koba1t
Copy link
Member

koba1t commented Feb 14, 2023

Thanks for your contributing!

I'm thinking about replacing minecraft chart that is used to test valuesInline with istio gateway chart.

Could you try to add the test with istio gateway chart below minecraft chart tests?
I think that is better than rewriting existing test cases.

@koba1t
Copy link
Member

koba1t commented Feb 14, 2023

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 14, 2023
@KnVerey
Copy link
Contributor

KnVerey commented Feb 14, 2023

Agreed, I would prefer a dedicated test case that shows the bug fix specifically (ideally as small and specific as possible). I'm also wondering why we use mergo here instead of our own kyaml/yaml/merge2... if we had that test in place, perhaps we could also try getting rid of the dependency instead of upgrading it?

@krzysiekg
Copy link
Contributor Author

No problem, I will write separate tests for this. Once I have them I'll also try and replace mergo with kyaml/yaml/merge2 and see if it breaks anything.

@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 14, 2023
@KnVerey
Copy link
Contributor

KnVerey commented Mar 22, 2023

/triage under-consideration
/kind bug
/priority backlog

@k8s-ci-robot k8s-ci-robot added triage/under-consideration kind/bug Categorizes issue or PR as related to a bug. priority/backlog Higher priority than priority/awaiting-more-evidence. labels Mar 22, 2023
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 20, 2023
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle rotten
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jul 20, 2023
@vladfr
Copy link

vladfr commented Aug 22, 2023

@krzysiekg Hi, did you get a chance to write those tests?

@superbrothers
Copy link
Contributor

superbrothers commented Sep 24, 2023

@KnVerey @koba1t I am facing #4905 too. I have created #5342 with an additional small dedicated test case that reproduces the problem. I would like to ask you to check it.

@krzysiekg
Copy link
Contributor Author

Sorry for the long silence.

I did write the test and replaced mergo with kyaml/yaml/merge2. I also looked into both packages a bit. The tests pass but I'm not certain that merge2 is a drop-in replacement for mergo. First, it has no concept of merge with override. I tried merges both with and without $patch: replace but it doesn't make any difference with current tests and I can't really tell which one is closer.

Since kustomize roadmap states that helmCharts field is going to be removed (is that still true?), I'm not sure if changing this and potentially breaking people's configs is worth it. But I would like to listen what maintainers think. WDYT @koba1t @KnVerey?

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 26, 2023
@k8s-ci-robot
Copy link
Contributor

This PR has multiple commits, and the default merge method is: merge.
You can request commits to be squashed using the label: tide/merge-method-squash

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.

@koba1t
Copy link
Member

koba1t commented Dec 7, 2023

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 7, 2023
Comment on lines 204 to 229
switch p.ValuesMerge {
case valuesMergeOptionOverride:
err = mergo.Merge(
&chValues, p.ValuesInline, mergo.WithOverride)
outValues, err = merge2.Merge(inlineValues, chValues, kyaml.MergeOptions{})
case valuesMergeOptionMerge:
err = mergo.Merge(&chValues, p.ValuesInline)
outValues, err = merge2.Merge(chValues, inlineValues, kyaml.MergeOptions{})
}
Copy link
Member

Choose a reason for hiding this comment

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

Override option with kyaml/yaml/merge2 lib can be achieved without extra parameters, just by passing src and dest in different order.

Could you add any comments about the above information?
I think this code is a little confusing what is doing because the above two lines only have different argument orders.

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 point! I added the explanation in the code.

Unrelated, but I also decided to copy the value before merging, so that the original values are preserved after the merge. Someone might still want to use it.

@koba1t
Copy link
Member

koba1t commented Dec 21, 2023

I think this change looks almost good, and we can merge.
But, I want to get checks from others.

@natasha41575
Hi! I don't have permission to run Actions on this PR.
Could you run CI, and Could you give this PR another check?

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closed this PR.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

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.

@krzysiekg
Copy link
Contributor Author

/reopen

@k8s-ci-robot
Copy link
Contributor

@krzysiekg: Failed to re-open PR: state cannot be changed. The fix-empty-map-merge branch was force-pushed or recreated.

In response to this:

/reopen

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.

@krzysiekg
Copy link
Contributor Author

/reopen

@k8s-ci-robot k8s-ci-robot reopened this Jan 23, 2024
@k8s-ci-robot
Copy link
Contributor

@krzysiekg: Reopened this PR.

In response to this:

/reopen

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.

Copy link
Member

@koba1t koba1t left a comment

Choose a reason for hiding this comment

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

Hi @krzysiekg
This PR almost looks good to me!
I plan to merge it.

But, I found a scenario of tests that are better to take.
Could you add any tests?

@krzysiekg
Copy link
Contributor Author

I added the test for valuesMerge: replace. After using replace option myself, I think it either needs some more clarification in the docs or deprecation and removal.

I think it functionality is limited but it is hard to tell how many people actually use it, so maybe it is better to keep it around. It does not replace the default values file from the chart (I would expect that). It only can replace the values file defined in the kustomization file with the values inline. But since it has to be the same kustomization file, people can just pass everything as inline values of as values file. And you can't use it to replace the values when you include the kustomization into another kustomization as resource, because at that point, helm chart is already inflated.

But it is not the kustomize issue either. Afaict helm do not offer a way to ignore the default values file that a chart comes with (other than removing the files from the chart, which is not a good approach imho).

@krzysiekg
Copy link
Contributor Author

Lint check was failing on make check-license. It was passing locally though. I saw that there was some issue with license headers on main branch so I rebased.

@koba1t
Copy link
Member

koba1t commented Jan 31, 2024

Lint check was failing on make check-license. It was passing locally though. I saw that there was some issue with license headers on main branch so I rebased.

Thanks!

@koba1t
Copy link
Member

koba1t commented Jan 31, 2024

I added the test for valuesMerge: replace. After using replace option myself, I think it either needs some more clarification in the docs or deprecation and removal.

I agree with your opinion. I think the valuesMerge: replace field doesn't have enough explanation, and I think it is not used by many people.
We need to consider deprecating that. But I feel we can not delete it with this PR and keep this function now because maybe some users use this field.

@koba1t
Copy link
Member

koba1t commented Jan 31, 2024

Hi @krzysiekg

Thanks for your long working!
I feel this PR looks good!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 31, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: koba1t, krzysiekg

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 31, 2024
@k8s-ci-robot k8s-ci-robot merged commit b1b61ad into kubernetes-sigs:master Jan 31, 2024
9 checks passed
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. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/backlog Higher priority than priority/awaiting-more-evidence. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/under-consideration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Helm and Kustomize Helm have different results
7 participants