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:
James Nugent 2016-06-23 21:14:09 +01:00
parent 983e4f13c6
commit 2356afde84
1 changed files with 6 additions and 3 deletions

View File

@ -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)