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 error during expansion of !!merge <<:
anchor tags
#4383
Fix error during expansion of !!merge <<:
anchor tags
#4383
Conversation
@RafaeLeal: This PR has multiple commits, and the default merge method is: merge. 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. |
Welcome @RafaeLeal! |
Hi @RafaeLeal. 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 Once the patch is verified, the new status will be reflected by the 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. |
/label tide/merge-method-squash |
I believe we have two corner cases that we need to take a look: The first one I believe we can manage, just need to think about the possible cases. We could have, as simple comment as possible: apiVersion: v1
kind: MergeTagTest
metadata:
name: test
spec:
color:
# red color
rgb: "#FF0000" And that is simple enough, but we could also have comments on merge tags, and we need to think about it. apiVersion: v1
kind: MergeTagTest
metadata:
name: test
spec:
color: &base-color
# red color
rgb: "#FF0000"
primaryColor:
# use the same base color
<<: *base-color and then we expand, we should decide:
On merge comments, we have some other corner cases:
color: &base-color
rgb: "#FF0000" # red color
primaryColor:
<<: *base-color # use same base color We have a couple of options.. we could transform to head comment.. and we can decide if we want to transform one or both: color:
rgb: "#FF0000" # red color
primaryColor:
# red color
rgb: "#FF0000" # use same base color we could also adopt a delimiter primaryColor:
rgb: "#FF0000" # red color; use same base color
color: &base-color
# red color
rgb: "#FF0000"
primaryColor: &primary-color
# use same base color
<<: *base-color
alpha: 0.5
secondaryColor:
# mixing colors
<<: *base-color
<<: *primary-color If we do decide to copy the comments, we are going to need to deal with how we order that.. and we can just get all merge comments on top of the mapping node. secondaryColor:
# red color
# use same base color
# mixing colors
rgb: "#FF0000"
alpha: 0.5 Let me know what you think |
On the other problem, it seems that for some reason I broke the json serialization.. It's failing the |
/cc |
I managed to fix this adding a new yaml filter |
/ok-to-test |
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 a couple new observations, but only the question about unhandled errors is a blocker for me. Otherwise this is ready to go!
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: KnVerey, RafaeLeal 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 |
…igs#4383) * WIP * Fix merge corner cases * Add test for explicit !!merge tag * Fix tests * Cleanup * Cleanup * Fix deanchoring lists * Add test case for keeping comments * Add MapEntrySetter and fix json marshalling after deanchoring * Keep duplicated keys * Move MergeTag definition to yaml alias * Remove go-spew from api * Add support for sequence nodes on merge tags * Add docstring to MapEntrySetter.Key * Add docstring to MapEntrySetter struct * Add tests to MapEntrySetter * Fix duplicate merge key * Revert whitespace changes on forked go-yaml * Remove AssocMapEntry function * Refactoring merge order * Return errors on VisitFields and PipeE * Add tests for each non-conforming map merges
Problem
Using yamls with
<<: *anchor
with or without the tag!!merge
tag is leading to an error:A lot of apps distributes YAMLs that use that, so even if you're not using it, you may rely on some distribution like Tekton's or Knative's:
Solution
I'm not familiar with the code base, but I tried to understand where we were doing the de-anchoring following this PR
https://github.com/kubernetes-sigs/kustomize/pull/4187/files
Related Issues