-
Notifications
You must be signed in to change notification settings - Fork 24k
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
lib/ansible/utils/vars.py - def merge_hash - fix for append / prepend when merging vars are equal #79312
base: devel
Are you sure you want to change the base?
Conversation
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.
tests and changelog? https://docs.ansible.com/ansible/latest/community/contributions.html
…when-vars-are-equal.yml - add changelog fragment for PR ansible#79312
…when-vars-are-equal.yml - add changelog fragment for PR ansible#79312
d8d1573
to
70bf94b
Compare
@bcoca I believe I have resolved your concerns. Can you have another look? Thanks, Aaron |
lib/ansible/utils/vars.py
Outdated
# (this `if` can be remove without impact on the function | ||
# except performance) | ||
if x == {} or x == y: | ||
if x == {} or (x == y and list_merge != 'append' and list_merge != 'prepend'): |
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.
list_merge not in ('append', 'prepend')
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 also add a test to prevent regressions?
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 thought you might ask about not in
- I'll get it added.
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.
Hey @bcoca, I made the code change. As far as the test goes, I'll need to dig into that as I'm not familiar with the creation of tests yet in this repo.
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 also add a test to prevent regressions?
@bcoca Do you have any guides on how to create regression tests?
lib/ansible/utils/vars.py
Outdated
# (this `if` can be remove without impact on the function | ||
# except performance) | ||
if x == {} or x == y: | ||
if x == {} or (x == y and list_merge != 'append' and list_merge != 'prepend'): |
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 also add a test to prevent regressions?
note: not for this PR, but perpend_unique/append_unique might be worth adding to keep the case in which the preexisting behavior is desired. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
The branch needs rebasing. |
…when-vars-are-equal.yml - add changelog fragment for PR ansible#79312
6401f65
to
f7d8137
Compare
f7d8137
to
016f134
Compare
…when-vars-are-equal.yml - add changelog fragment for PR ansible#79312
@webknjaz I have rebased with ...
|
@bcoca I have ran the following tests according to the guide...
|
FTR the VyOS failure is unrelated. |
This needs to be rebased to unblock the CI. |
…when-vars-are-equal.yml - add changelog fragment for PR ansible#79312
016f134
to
c1219c9
Compare
This comment was marked as abuse.
This comment was marked as abuse.
done! |
The last piece to getting this completed AFAIK is getting the regression test in place that @bcoca requested. If someone has a guide or even an example of a similar regression test, I can get that implemented in this PR. |
SUMMARY
Resolves #79293
ISSUE TYPE
COMPONENT NAME
resolves
combine()
filter plugin not appending / prepending properly when the two vars to be combined are equalADDITIONAL INFORMATION
test.yaml playbook used to reproduce issue
Before change:
After change: