mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Improve error message for COPY missing destination
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
c982ee805d
commit
5d05a82913
2 changed files with 6 additions and 6 deletions
|
@ -235,7 +235,7 @@ func parseLabel(req parseRequest) (*LabelCommand, error) {
|
||||||
|
|
||||||
func parseAdd(req parseRequest) (*AddCommand, error) {
|
func parseAdd(req parseRequest) (*AddCommand, error) {
|
||||||
if len(req.args) < 2 {
|
if len(req.args) < 2 {
|
||||||
return nil, errAtLeastTwoArguments("ADD")
|
return nil, errNoDestinationArgument("ADD")
|
||||||
}
|
}
|
||||||
flChown := req.flags.AddString("chown", "")
|
flChown := req.flags.AddString("chown", "")
|
||||||
if err := req.flags.Parse(); err != nil {
|
if err := req.flags.Parse(); err != nil {
|
||||||
|
@ -250,7 +250,7 @@ func parseAdd(req parseRequest) (*AddCommand, error) {
|
||||||
|
|
||||||
func parseCopy(req parseRequest) (*CopyCommand, error) {
|
func parseCopy(req parseRequest) (*CopyCommand, error) {
|
||||||
if len(req.args) < 2 {
|
if len(req.args) < 2 {
|
||||||
return nil, errAtLeastTwoArguments("COPY")
|
return nil, errNoDestinationArgument("COPY")
|
||||||
}
|
}
|
||||||
flChown := req.flags.AddString("chown", "")
|
flChown := req.flags.AddString("chown", "")
|
||||||
flFrom := req.flags.AddString("from", "")
|
flFrom := req.flags.AddString("from", "")
|
||||||
|
@ -622,8 +622,8 @@ func errExactlyOneArgument(command string) error {
|
||||||
return errors.Errorf("%s requires exactly one argument", command)
|
return errors.Errorf("%s requires exactly one argument", command)
|
||||||
}
|
}
|
||||||
|
|
||||||
func errAtLeastTwoArguments(command string) error {
|
func errNoDestinationArgument(command string) error {
|
||||||
return errors.Errorf("%s requires at least two arguments", command)
|
return errors.Errorf("%s requires at least two arguments, but only one was provided. Destination could not be determined.", command)
|
||||||
}
|
}
|
||||||
|
|
||||||
func errBlankCommandNames(command string) error {
|
func errBlankCommandNames(command string) error {
|
||||||
|
|
|
@ -45,7 +45,7 @@ func TestCommandsAtLeastOneArgument(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCommandsAtLeastTwoArgument(t *testing.T) {
|
func TestCommandsNoDestinationArgument(t *testing.T) {
|
||||||
commands := []string{
|
commands := []string{
|
||||||
"ADD",
|
"ADD",
|
||||||
"COPY",
|
"COPY",
|
||||||
|
@ -55,7 +55,7 @@ func TestCommandsAtLeastTwoArgument(t *testing.T) {
|
||||||
ast, err := parser.Parse(strings.NewReader(command + " arg1"))
|
ast, err := parser.Parse(strings.NewReader(command + " arg1"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, err = ParseInstruction(ast.AST.Children[0])
|
_, err = ParseInstruction(ast.AST.Children[0])
|
||||||
assert.EqualError(t, err, errAtLeastTwoArguments(command).Error())
|
assert.EqualError(t, err, errNoDestinationArgument(command).Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue