provisioner/shell: rename "path" to "script"

This commit is contained in:
Mitchell Hashimoto 2013-06-27 10:56:46 -07:00
parent 7720be6d84
commit 09fabf1e22
2 changed files with 12 additions and 12 deletions

View File

@ -26,7 +26,7 @@ type config struct {
Inline []string
// The local path of the shell script to upload and execute.
Path string
Script string
// An array of multiple scripts to run.
Scripts []string
@ -73,12 +73,12 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
errs := make([]error, 0)
if p.config.Path != "" && len(p.config.Scripts) > 0 {
errs = append(errs, errors.New("Only one of path or scripts can be specified."))
if p.config.Script != "" && len(p.config.Scripts) > 0 {
errs = append(errs, errors.New("Only one of script or scripts can be specified."))
}
if p.config.Path != "" {
p.config.Scripts = []string{p.config.Path}
if p.config.Script != "" {
p.config.Scripts = []string{p.config.Script}
}
if len(p.config.Scripts) == 0 && p.config.Inline == nil {

View File

@ -35,11 +35,11 @@ func TestProvisionerPrepare_Defaults(t *testing.T) {
}
}
func TestProvisionerPrepare_Path(t *testing.T) {
func TestProvisionerPrepare_Script(t *testing.T) {
config := testConfig()
delete(config, "inline")
config["path"] = "/this/should/not/exist"
config["script"] = "/this/should/not/exist"
p := new(Provisioner)
err := p.Prepare(config)
if err == nil {
@ -53,7 +53,7 @@ func TestProvisionerPrepare_Path(t *testing.T) {
}
defer os.Remove(tf.Name())
config["path"] = tf.Name()
config["script"] = tf.Name()
p = new(Provisioner)
err = p.Prepare(config)
if err != nil {
@ -61,12 +61,12 @@ func TestProvisionerPrepare_Path(t *testing.T) {
}
}
func TestProvisionerPrepare_PathAndInline(t *testing.T) {
func TestProvisionerPrepare_ScriptAndInline(t *testing.T) {
var p Provisioner
config := testConfig()
delete(config, "inline")
delete(config, "path")
delete(config, "script")
err := p.Prepare(config)
if err == nil {
t.Fatal("should have error")
@ -80,14 +80,14 @@ func TestProvisionerPrepare_PathAndInline(t *testing.T) {
defer os.Remove(tf.Name())
config["inline"] = []interface{}{"foo"}
config["path"] = tf.Name()
config["script"] = tf.Name()
err = p.Prepare(config)
if err == nil {
t.Fatal("should have error")
}
}
func TestProvisionerPrepare_PathAndScripts(t *testing.T) {
func TestProvisionerPrepare_ScriptAndScripts(t *testing.T) {
var p Provisioner
config := testConfig()