core: Fix interpolation of unknown multi-variables
This commit test "TestContext2Input_moduleComputedOutputElement" by ensuring that we treat a count of zero and non-reified resources independently rather than returning an empty list for both, which results in an interpolation failure when using the element function or indexing.
This commit is contained in:
parent
983e4f13c6
commit
2356afde84
|
@ -162,7 +162,6 @@ func (i *Interpolater) valueModuleVar(
|
|||
} else {
|
||||
// Same reasons as the comment above.
|
||||
result[n] = unknownVariable()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -485,11 +484,15 @@ func (i *Interpolater) computeResourceMultiVariable(
|
|||
err)
|
||||
}
|
||||
|
||||
// If we have no module in the state yet or count, return empty
|
||||
if module == nil || len(module.Resources) == 0 || count == 0 {
|
||||
// If count is zero, we return an empty list
|
||||
if count == 0 {
|
||||
return &ast.Variable{Type: ast.TypeList, Value: []ast.Variable{}}, nil
|
||||
}
|
||||
|
||||
// If we have no module in the state yet or count, return unknown
|
||||
if module == nil || len(module.Resources) == 0 {
|
||||
return &unknownVariable, nil
|
||||
}
|
||||
var values []string
|
||||
for j := 0; j < count; j++ {
|
||||
id := fmt.Sprintf("%s.%d", v.ResourceId(), j)
|
||||
|
|
Loading…
Reference in New Issue