packer-cn/builder/docker/exec.go

27 lines
598 B
Go
Raw Normal View History

2013-11-09 01:00:57 -05:00
package docker
import (
"os/exec"
2018-01-22 20:21:10 -05:00
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/shell-local/localexec"
2013-11-09 01:00:57 -05:00
)
func runAndStream(cmd *exec.Cmd, ui packersdk.Ui) error {
2013-11-09 01:00:57 -05:00
args := make([]string, len(cmd.Args)-1)
copy(args, cmd.Args[1:])
// Scrub password from the log output.
capturedPassword := ""
for i, v := range args {
if v == "-p" || v == "--password" {
capturedPassword = args[i+1]
break
}
}
// run local command and stream output to UI.
return localexec.RunAndStream(cmd, ui, []string{capturedPassword})
2013-11-09 01:00:57 -05:00
}