Add support for symbolic chmod options#6778
Conversation
|
Ephemeral COPR build failed. @containers/packit-build please check. |
0d82f4b to
42d5139
Compare
nalind
left a comment
There was a problem hiding this comment.
Overall this looks very good to me. A couple of quibbles about using test helper functions that would shorten them, and a question about calling mode.Parse() multiple times when reading.
| } | ||
| // force ownership and/or permissions, if requested | ||
| if options.Chmod != "" { | ||
| p, err := mode.Parse(options.Chmod) |
There was a problem hiding this comment.
We call copierHandlerGetOne() for every item that we're reading. How expensive is this?
There was a problem hiding this comment.
Good question. I think the only way to avoid this would be to compute the result of mode.Parse before the calls to copierHandlerGetOne(), and pass it as an argument to the function. As it already takes a lot of arguments I don't love this, as it feels a bit ugly. I haven't benchmarked mode.Parse(), but it looks pretty efficient, exits out early if it just contains a numeric string, and obviously is only called if options.Chmod is set.
However I don't have strong feelings either way, if you think passing the result of mode.Parse() to copierHandlerGetOne() is preferable I'm happy to make the change to make that happen. Or if you have an alternative suggestion.
There was a problem hiding this comment.
Yeah, go ahead and initialize the mode.Set in the caller, and pass a pointer to it into copierHandlerGetOne() as an argument (probably with a more descriptive name, "chmod" as the Put handler calls it would be fine) so that it can be compared to nil where it's currently comparing options.Chmod to an empty string.
|
Thanks for the detailed review, @nalind! I'll fix these up tomorrow and push a fresh version. |
42d5139 to
f6861de
Compare
f6861de to
2094dca
Compare
I ended up not waiting 'til tomorrow and just doing it. Replaced a couple more I'm not sure what to do about the |
nalind
left a comment
There was a problem hiding this comment.
Please go ahead and make that change. I think we're going to want this to be rebased before merging.
| } | ||
| // force ownership and/or permissions, if requested | ||
| if options.Chmod != "" { | ||
| p, err := mode.Parse(options.Chmod) |
There was a problem hiding this comment.
Yeah, go ahead and initialize the mode.Set in the caller, and pass a pointer to it into copierHandlerGetOne() as an argument (probably with a more descriptive name, "chmod" as the Put handler calls it would be fine) so that it can be compared to nil where it's currently comparing options.Chmod to an empty string.
57ee0cf to
c5cea6e
Compare
Done, including the rebase. I haven't tested as heavily, as the tests aren't all working on my local machine as they should, but I'll trust in the CI tests for now. |
Changes look good, but usually I expect merge commits to be dropped during a rebase. Did you |
3d13151 to
443ac4d
Compare
Oh, apologies, I said I rebased but I actually just merged main, indeed, my bad. I made a fresh branch from latest main, and cherry-picked & manually reapplied & amended my changes to it. So hopefully this is better. |
|
Much, better, thanks! |
443ac4d to
d32a6f7
Compare
|
@containers/buildah-maintainers PTAL |
|
@nickjwhite looks like you may need to rebase this. |
|
Other than a few test tweaks, and a rebase |
d32a6f7 to
85942ea
Compare
This adds an optional Chmod string option to GetOptions and PutOptions. If set, this overrides the ChmodDirs and ChmodFiles options. If unset, they continue to work as before. The --chmod option to buildah add and buildah copy works with symbolic as well as numeric arguments. Fixes containers#6066 Signed-off-by: Nick White <git@njw.name>
85942ea to
7c3cb08
Compare
|
@TomSweeneyRedHat can you take another look please? I added the extra tests you suggested and rebased, so this should be ready to go. |
What type of PR is this?
/kind feature
What this PR does / why we need it:
This adds an optional Chmod string option to GetOptions and PutOptions. If set, this overrides the ChmodDirs and ChmodFiles options. If unset, they continue to work as before.
The --chmod option to buildah add and buildah copy works with symbolic as well as numeric arguments.
How to verify it
See extra bats tests and copier tests.
Which issue(s) this PR fixes:
Fixes #6066
Special notes for your reviewer:
Note that I'm not sure whether the extra tests in
commit_test.goadd much value over those incopier/copier_test.go, but I used them while working on this change, so I figured I'd just include them.Also I'm not sure if this is the way you want the vendored stuff to be included (I added the newly added directory after running 'make vendor') - let me know if I should do it differently.
#6732 suggested calling the new option in
GetOptions&PutOptionsChmodStr, but I choseChmodhere because I think it's shorter and clearer.Does this PR introduce a user-facing change?