From 0dd4a4d83fd97ec7c96d63aed5b7feb051447ece Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 30 Jul 2013 10:41:02 -0700 Subject: [PATCH] packer/plugin: clean up stderr --- packer/plugin/client.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packer/plugin/client.go b/packer/plugin/client.go index 69e273f8d..abad90234 100644 --- a/packer/plugin/client.go +++ b/packer/plugin/client.go @@ -8,6 +8,7 @@ import ( "github.com/mitchellh/packer/packer" packrpc "github.com/mitchellh/packer/packer/rpc" "io" + "io/ioutil" "log" "net/rpc" "os" @@ -99,6 +100,10 @@ func NewClient(config *ClientConfig) (c *Client) { config.StartTimeout = 1 * time.Minute } + if config.Stderr == nil { + config.Stderr = ioutil.Discard + } + c = &Client{config: config} if config.Managed { managedClients = append(managedClients, c) @@ -300,10 +305,7 @@ func (c *Client) logStderr(r io.Reader) { line, err := bufR.ReadString('\n') if line != "" { log.Printf("%s: %s", c.config.Cmd.Path, line) - - if c.config.Stderr != nil { - c.config.Stderr.Write([]byte(line)) - } + c.config.Stderr.Write([]byte(line)) } if err == io.EOF {