mirror of https://github.com/docker/docs.git
FIX #1914 Reject command lines with trailing flags
Signed-off-by: David Gageot <david@gageot.net>
This commit is contained in:
parent
6a5219b879
commit
cd80b70d26
|
|
@ -1,7 +1,6 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -21,10 +20,6 @@ import (
|
|||
"github.com/docker/machine/libmachine/swarm"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrDriverNotRecognized = errors.New("Driver not recognized.")
|
||||
)
|
||||
|
||||
func cmdCreate(c *cli.Context) {
|
||||
var (
|
||||
driver drivers.Driver
|
||||
|
|
@ -56,6 +51,10 @@ func cmdCreate(c *cli.Context) {
|
|||
log.Fatal("You must specify a machine name")
|
||||
}
|
||||
|
||||
if len(c.Args()) > 1 {
|
||||
log.Fatalf("Invalid command line. Found extra arguments %v", c.Args()[1:])
|
||||
}
|
||||
|
||||
validName := host.ValidateHostName(name)
|
||||
if !validName {
|
||||
log.Fatal("Error creating machine: ", mcnerror.ErrInvalidHostname)
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ load ${BASE_TEST_DIR}/helpers.bash
|
|||
[[ ${lines[0]} == "Error creating machine: Machine A already exists" ]]
|
||||
}
|
||||
|
||||
@test "none: extraneous argument is ignored in name 'machine create -d none --url none a foo'" {
|
||||
run machine create -d none a foo
|
||||
@test "none: fail with extra argument 'machine create -d none --url none a extra'" {
|
||||
run machine create -d none --url none a extra
|
||||
[ "$status" -eq 1 ]
|
||||
[[ ${lines[0]} == "Host already exists: \"a\"" ]]
|
||||
[[ ${lines[0]} == "Invalid command line. Found extra arguments [extra]" ]]
|
||||
}
|
||||
|
||||
@test "none: create with weird but valid name succeeds 'machine create -d none --url none 0'" {
|
||||
|
|
|
|||
Loading…
Reference in New Issue