Use consistent name for errors

This prevents inconsistent errors when using a symlink, or when renaming
the binary;

Before this change;

    ln -s $(which docker) toto
    ./toto rune
    docker: 'rune' is not a docker command.

    ./toto run daslkjadslkjdaslkj
    Unable to find image 'adslkjadslakdsj:latest' locally
    ./toto: Error response from daemon: pull access denied for adslkjadslakdsj, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.

After this change:

    ln -s $(which docker) toto
    ./toto rune
    docker: 'rune' is not a docker command.

    ./toto run daslkjadslkjdaslkj
    Unable to find image 'adslkjadslakdsj:latest' locally
    docker: Error response from daemon: pull access denied for adslkjadslakdsj, repository does not exist or may require 'docker login': denied: requested access to the resource is den>

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-06-09 16:19:45 +02:00
parent 8f14db8df2
commit a3af1f47da
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 2 additions and 3 deletions

View File

@ -4,7 +4,6 @@ import (
"context" "context"
"fmt" "fmt"
"io" "io"
"os"
"runtime" "runtime"
"strings" "strings"
"syscall" "syscall"
@ -282,9 +281,9 @@ func attachContainer(
func reportError(stderr io.Writer, name string, str string, withHelp bool) { func reportError(stderr io.Writer, name string, str string, withHelp bool) {
str = strings.TrimSuffix(str, ".") + "." str = strings.TrimSuffix(str, ".") + "."
if withHelp { if withHelp {
str += "\nSee '" + os.Args[0] + " " + name + " --help'." str += "\nSee 'docker " + name + " --help'."
} }
fmt.Fprintf(stderr, "%s: %s\n", os.Args[0], str) fmt.Fprintln(stderr, "docker:", str)
} }
// if container start fails with 'not found'/'no such' error, return 127 // if container start fails with 'not found'/'no such' error, return 127