Commit 0dd4a4d8 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

packer/plugin: clean up stderr

parent 52dbb3c4
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
packrpc "github.com/mitchellh/packer/packer/rpc" packrpc "github.com/mitchellh/packer/packer/rpc"
"io" "io"
"io/ioutil"
"log" "log"
"net/rpc" "net/rpc"
"os" "os"
...@@ -99,6 +100,10 @@ func NewClient(config *ClientConfig) (c *Client) { ...@@ -99,6 +100,10 @@ func NewClient(config *ClientConfig) (c *Client) {
config.StartTimeout = 1 * time.Minute config.StartTimeout = 1 * time.Minute
} }
if config.Stderr == nil {
config.Stderr = ioutil.Discard
}
c = &Client{config: config} c = &Client{config: config}
if config.Managed { if config.Managed {
managedClients = append(managedClients, c) managedClients = append(managedClients, c)
...@@ -300,11 +305,8 @@ func (c *Client) logStderr(r io.Reader) { ...@@ -300,11 +305,8 @@ func (c *Client) logStderr(r io.Reader) {
line, err := bufR.ReadString('\n') line, err := bufR.ReadString('\n')
if line != "" { if line != "" {
log.Printf("%s: %s", c.config.Cmd.Path, 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 { if err == io.EOF {
break break
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment