@@ -142,7 +142,7 @@ type Schema struct {
142142 // element type is a complex structure, potentially with its own lifecycle.
143143 Elem interface {}
144144
145- // The follow fields are only valid for a TypeSet type.
145+ // The following fields are only valid for a TypeSet type.
146146 //
147147 // Set defines a function to determine the unique ID of an item so that
148148 // a proper set can be built.
@@ -902,7 +902,7 @@ func (m schemaMap) validate(
902902 "%s: this field cannot be set" , k )}
903903 }
904904
905- return m .validatePrimitive (k , raw , schema , c )
905+ return m .validateType (k , raw , schema , c )
906906}
907907
908908func (m schemaMap ) validateList (
@@ -915,7 +915,7 @@ func (m schemaMap) validateList(
915915 rawV := reflect .ValueOf (raw )
916916 if rawV .Kind () != reflect .Slice {
917917 return nil , []error {fmt .Errorf (
918- "%s: should be a list " , k )}
918+ "%s: should be an array " , k )}
919919 }
920920
921921 // Now build the []interface{}
@@ -936,8 +936,7 @@ func (m schemaMap) validateList(
936936 // This is a sub-resource
937937 ws2 , es2 = m .validateObject (key , t .Schema , c )
938938 case * Schema :
939- // This is some sort of primitive
940- ws2 , es2 = m .validatePrimitive (key , raw , t , c )
939+ ws2 , es2 = m .validateType (key , raw , t , c )
941940 }
942941
943942 if len (ws2 ) > 0 {
@@ -1041,12 +1040,6 @@ func (m schemaMap) validatePrimitive(
10411040 }
10421041
10431042 switch schema .Type {
1044- case TypeSet :
1045- fallthrough
1046- case TypeList :
1047- return m .validateList (k , raw , schema , c )
1048- case TypeMap :
1049- return m .validateMap (k , raw , schema , c )
10501043 case TypeBool :
10511044 // Verify that we can parse this as the correct type
10521045 var n bool
@@ -1071,3 +1064,20 @@ func (m schemaMap) validatePrimitive(
10711064
10721065 return nil , nil
10731066}
1067+
1068+ func (m schemaMap ) validateType (
1069+ k string ,
1070+ raw interface {},
1071+ schema * Schema ,
1072+ c * terraform.ResourceConfig ) ([]string , []error ) {
1073+ switch schema .Type {
1074+ case TypeSet :
1075+ fallthrough
1076+ case TypeList :
1077+ return m .validateList (k , raw , schema , c )
1078+ case TypeMap :
1079+ return m .validateMap (k , raw , schema , c )
1080+ default :
1081+ return m .validatePrimitive (k , raw , schema , c )
1082+ }
1083+ }
0 commit comments