-
Notifications
You must be signed in to change notification settings - Fork 24k
module_utils: Consolidate set_owner_if_different & set_group_if_different #75742
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
base: devel
Are you sure you want to change the base?
Conversation
7ec2820
to
25ee3d0
Compare
25ee3d0
to
68ab424
Compare
/rebuild |
68ab424
to
d58ce51
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@moreati could you rebase? |
…rent This merges implementations of `AnsibleModule.set_owner_if_different()` & `AnsibleModule.set_group_if_different()` into a single method. The benefits are - reduction in code duplication - makes possible halving the number of calls to `os.lchown()` when the copy module sets both owner and group. There should be no outward change in behavior. The two original methods become thin wrappers around the new one. This PR is related to ansible#75741. If both are merged, then the second benefit above can be realised - by replacing calls in `copy.chown_recursive()`. Open questions: - Should this new method be public (without a leading underscore)? - Is there a better name?
d58ce51
to
8904e62
Compare
Would you mind adding a test? The change looks good to me. |
Can do. To clarify, which do you want
or something else? Edit: clarified option b removes the leading underscore |
Or (to bikeshed the name) if the function is to be public , then |
3d08885
to
786b378
Compare
The test
|
786b378
to
9542526
Compare
9542526
to
def9a22
Compare
Sorry for the wait @s-hertel, I only spotted your 👍 reaction yesterday. |
Spotted and suggested in code review by s-hertel Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com>
SUMMARY
This merges implementations of
AnsibleModule.set_owner_if_different()
&AnsibleMo 8000 dule.set_group_if_different()
into a single method. The benefits areos.lchown()
when the copy module sets both owner and group.There should be no outward change in behavior. The two original methods become thin wrappers around the new one.
ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
This PR is related to #75741. If both are merged, then the second benefit above can be realised - by replacing calls in
copy.chown_recursive()
.