mirror of
https://github.com/docker/docs.git
synced 2026-11-05 00:14:17 +03:00
Merge pull request #1960 from dgageot/1914-create-ignores-trailing-options
FIX #1914 Reject command lines with trailing flags
This commit is contained in:
@@ -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'" {
|
||||
|
||||
Reference in New Issue
Block a user