-
Notifications
You must be signed in to change notification settings - Fork 18.7k
introduce workingdir
option for docker exec
#35661
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
Conversation
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
I've ran |
Design LGTM |
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.
looks good to me, though can you add a test for it?
c259609
to
0ef331f
Compare
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.
Design LGTM
/cc @thaJeztah @dnephin
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.
Thanks, couple comments about the test.
integration/exec/main_test.go
Outdated
@@ -0,0 +1,33 @@ | |||
package exec |
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.
exec
is not a component (see https://github.com/moby/moby/tree/master/api/server/router). The component is container
so this should go in integration/container
.
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.
ok, I can move this to container.
integration/exec/workingdir_test.go
Outdated
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestExecWithWorkingDir(t *testing.T) { |
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.
We shouldn't write an integration test for option. How about just making this TestExec()
and we can add a bunch of fields to this single 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.
Do you mean you prefer a single, huge test to check all options and their correct behaviour ? Won't this make it harder to diagnose a build failure with a clear cause ?
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.
It shouldn't be any harder if the failure messages are written correctly.
If there are options that conflict with each other, or that significantly change the behaviour of other options then multiple tests might be necessary, but I don't think that's the case here. Most of the options are independent, and we don't need to run multiple extremely slow tests to check each independent option.
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.
right, but testing workdir require to set a custom command executed, while testing other options like env will require to run /bin/env
, etc...
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.
fair point. For those two cases I think env
works for both, since PWD
should be set. Is that right?
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.
implemented as 57c5631
@dnephin PR was updated 👍 |
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.
LGTM
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.
LGTM
Thanks!
integration/container/exec_test.go
Outdated
"foo", | ||
) | ||
require.NoError(t, err) | ||
defer client.ContainerRemove(ctx, container.ID, |
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.
This cleanup is automatically handled by defer setupTest(t)()
but I guess it doesn't hurt to have it, other than it might encourage others to add unnecessary cleanup to new tests.
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.
changes LGTM, but can you squash your commits (where needed)? Also while doing so, perhaps you can address @dnephin's nit https://github.com/moby/moby/pull/35661/files#r155046183
Then we can merge; if you can prepare a PR for the docker/cli it may just make it for 17.12
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
commits squashed |
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.
LGTM, thanks!
oh! looks like there's an issue with the Swagger definition;
|
@thaJeztah yes, this happened on a regular basis on this PR, I can't explain why. Used to re-run janky build with rebuild/janky tag. |
Yes, definitely! I actually started building from this PR to check what the diff was, but I'm currently on super-slow-hotel-wifi, and just emptied my image cache before I left the office 😂 Let me trigger CI again to see if it resolves itself 👍 |
Signed-off-by: Nicolas De Loof nicolas.deloof@gmail.com
- What I did
Implemented
WorkingDir
support for execs, as discussed on #8917- How I did it
introduced WorkingDir in API and used for new process to be ran, falling back to container's WorkingDir if not set.
- How to verify it
Need to forge API call or use client package
- Description for the changelog
Introduce option to configure woking directory to run additional process in a container with
exec
- A picture of a cute animal (not mandatory but encouraged)