Commit 4463083a authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

provisioner/shell: randomize default script name

parent d9fceaf3
......@@ -9,6 +9,7 @@ import (
"io"
"io/ioutil"
"log"
"math/rand"
"os"
"strings"
"time"
......@@ -19,8 +20,6 @@ import (
"github.com/mitchellh/packer/template/interpolate"
)
const DefaultRemotePath = "/tmp/script.sh"
type Config struct {
common.PackerConfig `mapstructure:",squash"`
......@@ -102,7 +101,8 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
}
if p.config.RemotePath == "" {
p.config.RemotePath = DefaultRemotePath
p.config.RemotePath = fmt.Sprintf(
"/tmp/script_%d.sh", rand.Intn(9999))
}
if p.config.Scripts == nil {
......
......@@ -30,7 +30,7 @@ func TestProvisionerPrepare_Defaults(t *testing.T) {
t.Fatalf("err: %s", err)
}
if p.config.RemotePath != DefaultRemotePath {
if p.config.RemotePath == "" {
t.Errorf("unexpected remote path: %s", p.config.RemotePath)
}
}
......
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