Commit f726ea28 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

provisioner/shell: Start working on shell provisioner

parent 81d8b207
......@@ -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) {
......
......@@ -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)
}
}
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