unknown collections in a flatmap

Unknown collections in a flatmap also need to be converted to unknown
values.
This commit is contained in:
James Bardin 2018-09-17 19:24:22 -04:00 committed by Martin Atkins
parent 78b8400766
commit 9d8ca4515e
1 changed files with 24 additions and 0 deletions

View File

@ -215,6 +215,12 @@ func hcl2ValueFromFlatmapObject(m map[string]string, prefix string, atys map[str
func hcl2ValueFromFlatmapTuple(m map[string]string, prefix string, etys []cty.Type) (cty.Value, error) { func hcl2ValueFromFlatmapTuple(m map[string]string, prefix string, etys []cty.Type) (cty.Value, error) {
var vals []cty.Value var vals []cty.Value
// if the container is unknown, there is no count string
listName := strings.TrimRight(prefix, ".")
if m[listName] == UnknownVariableValue {
return cty.UnknownVal(cty.Tuple(etys)), nil
}
countStr, exists := m[prefix+"#"] countStr, exists := m[prefix+"#"]
if !exists { if !exists {
return cty.NullVal(cty.Tuple(etys)), nil return cty.NullVal(cty.Tuple(etys)), nil
@ -247,6 +253,12 @@ func hcl2ValueFromFlatmapMap(m map[string]string, prefix string, ty cty.Type) (c
vals := make(map[string]cty.Value) vals := make(map[string]cty.Value)
ety := ty.ElementType() ety := ty.ElementType()
// if the container is unknown, there is no count string
listName := strings.TrimRight(prefix, ".")
if m[listName] == UnknownVariableValue {
return cty.UnknownVal(ty), nil
}
// We actually don't really care about the "count" of a map for our // We actually don't really care about the "count" of a map for our
// purposes here, but we do need to check if it _exists_ in order to // purposes here, but we do need to check if it _exists_ in order to
// recognize the difference between null (not set at all) and empty. // recognize the difference between null (not set at all) and empty.
@ -288,6 +300,12 @@ func hcl2ValueFromFlatmapMap(m map[string]string, prefix string, ty cty.Type) (c
func hcl2ValueFromFlatmapList(m map[string]string, prefix string, ty cty.Type) (cty.Value, error) { func hcl2ValueFromFlatmapList(m map[string]string, prefix string, ty cty.Type) (cty.Value, error) {
var vals []cty.Value var vals []cty.Value
// if the container is unknown, there is no count string
listName := strings.TrimRight(prefix, ".")
if m[listName] == UnknownVariableValue {
return cty.UnknownVal(ty), nil
}
countStr, exists := m[prefix+"#"] countStr, exists := m[prefix+"#"]
if !exists { if !exists {
return cty.NullVal(ty), nil return cty.NullVal(ty), nil
@ -323,6 +341,12 @@ func hcl2ValueFromFlatmapSet(m map[string]string, prefix string, ty cty.Type) (c
var vals []cty.Value var vals []cty.Value
ety := ty.ElementType() ety := ty.ElementType()
// if the container is unknown, there is no count string
listName := strings.TrimRight(prefix, ".")
if m[listName] == UnknownVariableValue {
return cty.UnknownVal(ty), nil
}
// We actually don't really care about the "count" of a set for our // We actually don't really care about the "count" of a set for our
// purposes here, but we do need to check if it _exists_ in order to // purposes here, but we do need to check if it _exists_ in order to
// recognize the difference between null (not set at all) and empty. // recognize the difference between null (not set at all) and empty.