lang/funcs: lookup() will only treat map as unknown if it is wholly unknown (#26427)
Fix for issue #26320 - this allows us to derive known values from partially known maps where we can, and may prevent unnecessary destroy/rebuild cycles during apply in some cases.
This commit is contained in:
parent
3933cbd491
commit
bb39fafbe5
|
@ -315,7 +315,7 @@ var LookupFunc = function.New(&function.Spec{
|
|||
mapVar := args[0]
|
||||
lookupKey := args[1].AsString()
|
||||
|
||||
if !mapVar.IsWhollyKnown() {
|
||||
if !mapVar.IsKnown() {
|
||||
return cty.UnknownVal(retType), nil
|
||||
}
|
||||
|
||||
|
|
|
@ -720,6 +720,14 @@ func TestLookup(t *testing.T) {
|
|||
cty.UnknownVal(cty.String),
|
||||
false,
|
||||
},
|
||||
{
|
||||
[]cty.Value{
|
||||
mapWithUnknowns,
|
||||
cty.StringVal("foo"),
|
||||
},
|
||||
cty.StringVal("bar"),
|
||||
false,
|
||||
},
|
||||
{
|
||||
[]cty.Value{
|
||||
simpleMap,
|
||||
|
|
Loading…
Reference in New Issue