provisioner/shell: Start working on shell provisioner

This commit is contained in:
Mitchell Hashimoto 2013-05-27 15:06:34 -07:00
parent 81d8b20730
commit f726ea2800
2 changed files with 25 additions and 0 deletions

View File

@ -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) {

View File

@ -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)
}
}