Skip to content

Carry #23159 : Use spf13/cobra for docker run and docker create#23253

Merged
thaJeztah merged 2 commits intomoby:masterfrom
vdemeester:carry-pr-23159
Jun 4, 2016
Merged

Carry #23159 : Use spf13/cobra for docker run and docker create#23253
thaJeztah merged 2 commits intomoby:masterfrom
vdemeester:carry-pr-23159

Conversation

@vdemeester
Copy link
Copy Markdown
Member

Carry #23159 with conflict resolving.
Closes #23159.


This PR builds off of #22769

As requested in #22769 (comment) this is a PoC to show that cobra and pflag will work for a more involved command like docker run.

dnephin added 2 commits June 4, 2016 13:55
Move container options into a struct so that tests should pass.
Remove unused FlagSet arg from Parse
Disable interspersed args on docker run

Signed-off-by: Daniel Nephin <[email protected]>
Return the correct status code on flag parsins errors.

Signed-off-by: Daniel Nephin <[email protected]>
@thaJeztah
Copy link
Copy Markdown
Member

Actually, looks like we're missing "see docker run --help" in the usage output;

old:

docker: "run" requires a minimum of 1 argument.
See 'docker run --help'.

Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Run a command in a new container

new

"docker run" requires at least 1 argument(s).

Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Run a command in a new container

Is that someone we need to fix here, or globally?

@thaJeztah
Copy link
Copy Markdown
Member

Other than that, re-LGTM

@vdemeester
Copy link
Copy Markdown
Member Author

@thaJeztah good point. It's something to do globally 😝
I'll do a follow-up to fix it 😉

@thaJeztah
Copy link
Copy Markdown
Member

ok LGTM, once we get a Windows CI node that isn't broken 😢

@thaJeztah
Copy link
Copy Markdown
Member

it's green! merging 👍

@thaJeztah thaJeztah merged commit 6b4a46f into moby:master Jun 4, 2016
@vdemeester vdemeester deleted the carry-pr-23159 branch June 4, 2016 17:03
@tianon
Copy link
Copy Markdown
Member

tianon commented Jun 6, 2016

Looks like there are still some edge cases to consider: 😢

$ docker run --name test --rm debian:sid sh -c 'echo hi'
hi
$ docker create --name test debian:sid sh -c 'echo hi'
invalid argument "echo hi" for c: strconv.ParseInt: parsing "echo hi": invalid syntax
See 'docker create --help'.

@thaJeztah
Copy link
Copy Markdown
Member

Darn, it's seeing -c as --cpu-shares?

@tianon
Copy link
Copy Markdown
Member

tianon commented Jun 6, 2016

Indeed, instead of stopping flag processing at the image name like docker run appears to successfully do. 😢

@tianon
Copy link
Copy Markdown
Member

tianon commented Jun 6, 2016

From the looks of the diff, it appears docker create is just missing flags.SetInterspersed(false)

@dnephin
Copy link
Copy Markdown
Member

dnephin commented Jun 6, 2016

Any command that expects extra flags after positional args needs to set flags.SetInterspersed(false).

That was done for run and a few others.

@thaJeztah
Copy link
Copy Markdown
Member

Cool, sounds like an easy fix (phew). Thanks for finding, @tianon! We should have a test for that as well

@justincormack
Copy link
Copy Markdown
Contributor

Seems to be an issue see #23329

@dnephin dnephin mentioned this pull request Jun 7, 2016
43 tasks
dnephin pushed a commit to dnephin/docker that referenced this pull request Apr 17, 2017
Carry moby#23159 : Use spf13/cobra for `docker run` and `docker create`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants