Commit ca312264 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Merge pull request #2270 from mitchellh/b-shell-random

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