Revert "provisioner/remote-exec: fail on first inline script with bad exit code (#11155)"

This reverts commit d2047d714e.
This commit is contained in:
Mitchell Hashimoto 2017-02-06 16:51:51 -08:00
parent cbbc1cfdad
commit 640faf18c3
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 19 additions and 19 deletions

View File

@ -8,6 +8,7 @@ import (
"io/ioutil"
"log"
"os"
"strings"
"sync/atomic"
"time"
@ -78,11 +79,13 @@ func applyFn(ctx context.Context) error {
// generateScripts takes the configuration and creates a script from each inline config
func generateScripts(d *schema.ResourceData) ([]string, error) {
var scripts []string
var lines []string
for _, l := range d.Get("inline").([]interface{}) {
scripts = append(scripts, l.(string))
lines = append(lines, l.(string))
}
return scripts, nil
lines = append(lines, "")
return []string{strings.Join(lines, "\n")}, nil
}
// collectScripts is used to collect all the scripts we need

View File

@ -3,11 +3,8 @@ package remoteexec
import (
"bytes"
"io"
"strings"
"testing"
"reflect"
"github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
@ -46,8 +43,6 @@ wget http://foobar
exit 0
`
var expectedInlineScriptsOut = strings.Split(expectedScriptOut, "\n")
func TestResourceProvider_generateScript(t *testing.T) {
p := Provisioner().(*schema.Provisioner)
conf := map[string]interface{}{
@ -63,7 +58,11 @@ func TestResourceProvider_generateScript(t *testing.T) {
t.Fatalf("err: %v", err)
}
if reflect.DeepEqual(out, expectedInlineScriptsOut) {
if len(out) != 1 {
t.Fatal("expected 1 out")
}
if out[0] != expectedScriptOut {
t.Fatalf("bad: %v", out)
}
}
@ -84,21 +83,19 @@ func TestResourceProvider_CollectScripts_inline(t *testing.T) {
t.Fatalf("err: %v", err)
}
if len(scripts) != 3 {
if len(scripts) != 1 {
t.Fatalf("bad: %v", scripts)
}
for i, script := range scripts {
var out bytes.Buffer
_, err = io.Copy(&out, script)
_, err = io.Copy(&out, scripts[0])
if err != nil {
t.Fatalf("err: %v", err)
}
if out.String() != expectedInlineScriptsOut[i] {
if out.String() != expectedScriptOut {
t.Fatalf("bad: %v", out.String())
}
}
}
func TestResourceProvider_CollectScripts_script(t *testing.T) {