mirror of
https://github.com/moby/moby.git
synced 2025-07-29 07:21:35 +03:00
Fix create command flags
Any command that expects extra flags after positional args needs to set flags.SetInterspersed(false). Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
@ -46,6 +46,8 @@ func NewCreateCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|||||||
cmd.SetFlagErrorFunc(flagErrorFunc)
|
cmd.SetFlagErrorFunc(flagErrorFunc)
|
||||||
|
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
|
flags.SetInterspersed(false)
|
||||||
|
|
||||||
flags.StringVar(&opts.name, "name", "", "Assign a name to the container")
|
flags.StringVar(&opts.name, "name", "", "Assign a name to the container")
|
||||||
|
|
||||||
// Add an explicit help that doesn't have a `-h` to prevent the conflict
|
// Add an explicit help that doesn't have a `-h` to prevent the conflict
|
||||||
|
@ -25,7 +25,7 @@ func (s *DockerSuite) TestCreateArgs(c *check.C) {
|
|||||||
if daemonPlatform == "windows" {
|
if daemonPlatform == "windows" {
|
||||||
c.Skip("Fails on Windows CI")
|
c.Skip("Fails on Windows CI")
|
||||||
}
|
}
|
||||||
out, _ := dockerCmd(c, "create", "busybox", "command", "arg1", "arg2", "arg with space")
|
out, _ := dockerCmd(c, "create", "busybox", "command", "arg1", "arg2", "arg with space", "-c", "flags")
|
||||||
|
|
||||||
cleanedContainerID := strings.TrimSpace(out)
|
cleanedContainerID := strings.TrimSpace(out)
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ func (s *DockerSuite) TestCreateArgs(c *check.C) {
|
|||||||
c.Assert(string(cont.Path), checker.Equals, "command", check.Commentf("Unexpected container path. Expected command, received: %s", cont.Path))
|
c.Assert(string(cont.Path), checker.Equals, "command", check.Commentf("Unexpected container path. Expected command, received: %s", cont.Path))
|
||||||
|
|
||||||
b := false
|
b := false
|
||||||
expected := []string{"arg1", "arg2", "arg with space"}
|
expected := []string{"arg1", "arg2", "arg with space", "-c", "flags"}
|
||||||
for i, arg := range expected {
|
for i, arg := range expected {
|
||||||
if arg != cont.Args[i] {
|
if arg != cont.Args[i] {
|
||||||
b = true
|
b = true
|
||||||
|
Reference in New Issue
Block a user