Use stderr instead of logrus for CLI error messages

Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
Doug Davis
2015-05-12 17:22:41 -07:00
parent 37cb2a15bf
commit 0024935f64
11 changed files with 71 additions and 25 deletions
+1 -2
View File
@@ -17,7 +17,6 @@ import (
"strconv"
"strings"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/api"
"github.com/docker/docker/graph"
"github.com/docker/docker/pkg/archive"
@@ -192,7 +191,7 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
// windows: show error message about modified file permissions
// FIXME: this is not a valid warning when the daemon is running windows. should be removed once docker engine for windows can build.
if runtime.GOOS == "windows" {
logrus.Warn(`SECURITY WARNING: You are building a Docker image from Windows against a Linux Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.`)
fmt.Fprintln(cli.err, `SECURITY WARNING: You are building a Docker image from Windows against a Linux Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.`)
}
var body io.Reader
+8
View File
@@ -63,6 +63,14 @@ var funcMap = template.FuncMap{
},
}
func (cli *DockerCli) Out() io.Writer {
return cli.out
}
func (cli *DockerCli) Err() io.Writer {
return cli.err
}
func (cli *DockerCli) getMethod(args ...string) (func(...string) error, bool) {
camelArgs := make([]string, len(args))
for i, s := range args {
+2 -2
View File
@@ -71,7 +71,7 @@ func (cli *DockerCli) CmdExec(args ...string) error {
defer func() {
logrus.Debugf("End of CmdExec(), Waiting for hijack to finish.")
if _, ok := <-hijacked; ok {
logrus.Errorf("Hijack did not finish (chan still open)")
fmt.Fprintln(cli.err, "Hijack did not finish (chan still open)")
}
}()
@@ -109,7 +109,7 @@ func (cli *DockerCli) CmdExec(args ...string) error {
if execConfig.Tty && cli.isTerminalIn {
if err := cli.monitorTtySize(execID, true); err != nil {
logrus.Errorf("Error monitoring TTY size: %s", err)
fmt.Fprintf(cli.err, "Error monitoring TTY size: %s\n", err)
}
}
+3 -3
View File
@@ -133,7 +133,7 @@ func (cli *DockerCli) CmdRun(args ...string) error {
defer func() {
logrus.Debugf("End of CmdRun(), Waiting for hijack to finish.")
if _, ok := <-hijacked; ok {
logrus.Errorf("Hijack did not finish (chan still open)")
fmt.Fprintln(cli.err, "Hijack did not finish (chan still open)")
}
}()
if config.AttachStdin || config.AttachStdout || config.AttachStderr {
@@ -183,7 +183,7 @@ func (cli *DockerCli) CmdRun(args ...string) error {
defer func() {
if *flAutoRemove {
if _, _, err = readBody(cli.call("DELETE", "/containers/"+createResponse.ID+"?v=1", nil, nil)); err != nil {
logrus.Errorf("Error deleting container: %s", err)
fmt.Fprintf(cli.err, "Error deleting container: %s\n", err)
}
}
}()
@@ -195,7 +195,7 @@ func (cli *DockerCli) CmdRun(args ...string) error {
if (config.AttachStdin || config.AttachStdout || config.AttachStderr) && config.Tty && cli.isTerminalOut {
if err := cli.monitorTtySize(createResponse.ID, false); err != nil {
logrus.Errorf("Error monitoring TTY size: %s", err)
fmt.Fprintf(cli.err, "Error monitoring TTY size: %s\n", err)
}
}
+3 -3
View File
@@ -30,7 +30,7 @@ func (cli *DockerCli) forwardAllSignals(cid string) chan os.Signal {
}
}
if sig == "" {
logrus.Errorf("Unsupported signal: %v. Discarding.", s)
fmt.Fprintf(cli.err, "Unsupported signal: %v. Discarding.\n", s)
}
if _, _, err := readBody(cli.call("POST", fmt.Sprintf("/containers/%s/kill?signal=%s", cid, sig), nil, nil)); err != nil {
logrus.Debugf("Error sending signal: %s", err)
@@ -96,7 +96,7 @@ func (cli *DockerCli) CmdStart(args ...string) error {
defer func() {
logrus.Debugf("CmdStart() returned, defer waiting for hijack to finish.")
if _, ok := <-hijacked; ok {
logrus.Errorf("Hijack did not finish (chan still open)")
fmt.Fprintln(cli.err, "Hijack did not finish (chan still open)")
}
cli.in.Close()
}()
@@ -149,7 +149,7 @@ func (cli *DockerCli) CmdStart(args ...string) error {
if *openStdin || *attach {
if tty && cli.isTerminalOut {
if err := cli.monitorTtySize(cmd.Arg(0), false); err != nil {
logrus.Errorf("Error monitoring TTY size: %s", err)
fmt.Fprintf(cli.err, "Error monitoring TTY size: %s\n", err)
}
}
if attchErr := <-cErr; attchErr != nil {
+1 -2
View File
@@ -5,7 +5,6 @@ import (
"fmt"
"runtime"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/api"
"github.com/docker/docker/api/types"
"github.com/docker/docker/autogen/dockerversion"
@@ -40,7 +39,7 @@ func (cli *DockerCli) CmdVersion(args ...string) error {
var v types.Version
if err := json.NewDecoder(stream).Decode(&v); err != nil {
logrus.Errorf("Error reading remote version: %s", err)
fmt.Fprintf(cli.err, "Error reading remote version: %s\n", err)
return err
}