From 3aa655ad3be1541e941b8534e87472f6ce8f9237 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 9 Oct 2014 16:31:24 -0700 Subject: [PATCH] helper/schema: test schema diffs with the interpolation splits --- builtin/providers/aws/structure.go | 8 ------ helper/schema/schema_test.go | 43 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/builtin/providers/aws/structure.go b/builtin/providers/aws/structure.go index 017123b94e..0feab680ed 100644 --- a/builtin/providers/aws/structure.go +++ b/builtin/providers/aws/structure.go @@ -188,14 +188,6 @@ func flattenInstances(list []elb.Instance) []string { // Takes the result of flatmap.Expand for an array of strings // and returns a []string func expandStringList(configured []interface{}) []string { - // here we special case the * expanded lists. For example: - // - // instances = ["${aws_instance.foo.*.id}"] - // - if len(configured) == 1 && strings.Contains(configured[0].(string), ",") { - return strings.Split(configured[0].(string), ",") - } - vs := make([]string, 0, len(configured)) for _, v := range configured { vs = append(vs, v.(string)) diff --git a/helper/schema/schema_test.go b/helper/schema/schema_test.go index 8190ff2a6c..d3305a6859 100644 --- a/helper/schema/schema_test.go +++ b/helper/schema/schema_test.go @@ -385,6 +385,49 @@ func TestSchemaMap_Diff(t *testing.T) { Err: false, }, + { + Schema: map[string]*Schema{ + "ports": &Schema{ + Type: TypeList, + Required: true, + Elem: &Schema{Type: TypeInt}, + }, + }, + + State: nil, + + Config: map[string]interface{}{ + "ports": []interface{}{1, "${var.foo}"}, + }, + + ConfigVariables: map[string]string{ + "var.foo": "2" + config.InterpSplitDelim + "5", + }, + + Diff: &terraform.InstanceDiff{ + Attributes: map[string]*terraform.ResourceAttrDiff{ + "ports.#": &terraform.ResourceAttrDiff{ + Old: "0", + New: "3", + }, + "ports.0": &terraform.ResourceAttrDiff{ + Old: "", + New: "1", + }, + "ports.1": &terraform.ResourceAttrDiff{ + Old: "", + New: "2", + }, + "ports.2": &terraform.ResourceAttrDiff{ + Old: "", + New: "5", + }, + }, + }, + + Err: false, + }, + { Schema: map[string]*Schema{ "ports": &Schema{