diff --git a/provisioner/shell/provisioner.go b/provisioner/shell/provisioner.go index 5561dc93c..ebd073fb0 100644 --- a/provisioner/shell/provisioner.go +++ b/provisioner/shell/provisioner.go @@ -3,11 +3,20 @@ package shell import ( + "github.com/mitchellh/mapstructure" "github.com/mitchellh/packer/packer" ) +const DefaultRemotePath = "/tmp/script.sh" + // TODO(mitchellh): config type config struct { + // The local path of the shell script to upload and execute. + Path string + + // The remote path where the local shell script will be uploaded to. + // This should be set to a writable file that is in a pre-existing directory. + RemotePath string } type Provisioner struct { @@ -15,6 +24,12 @@ type Provisioner struct { } func (p *Provisioner) Prepare(raw interface{}, ui packer.Ui) { + // TODO: errors + _ = mapstructure.Decode(raw, &p.config) + + if p.config.RemotePath == "" { + p.config.RemotePath = DefaultRemotePath + } } func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) { diff --git a/provisioner/shell/provisioner_test.go b/provisioner/shell/provisioner_test.go index 2f67b0160..d0f3c2126 100644 --- a/provisioner/shell/provisioner_test.go +++ b/provisioner/shell/provisioner_test.go @@ -13,3 +13,13 @@ func TestProvisioner_Impl(t *testing.T) { } } +func TestProvisionerPrepare_Defaults(t *testing.T) { + raw := map[string]interface{} {} + + p := &Provisioner{} + p.Prepare(raw, nil) + + if p.config.RemotePath != DefaultRemotePath { + t.Errorf("unexpected remote path: %s", p.config.RemotePath) + } +}