Merge pull request #427 from hashicorp/pselle/marked-conditionals
Unmark conditional values before checking their truthiness
This commit is contained in:
commit
42b83d915c
@ -624,6 +624,8 @@ func (e *ConditionalExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostic
|
|||||||
return cty.UnknownVal(resultType), diags
|
return cty.UnknownVal(resultType), diags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unmark result before testing for truthiness
|
||||||
|
condResult, _ = condResult.UnmarkDeep()
|
||||||
if condResult.True() {
|
if condResult.True() {
|
||||||
diags = append(diags, trueDiags...)
|
diags = append(diags, trueDiags...)
|
||||||
if convs[0] != nil {
|
if convs[0] != nil {
|
||||||
|
@ -1582,6 +1582,18 @@ EOT
|
|||||||
cty.DynamicVal,
|
cty.DynamicVal,
|
||||||
0,
|
0,
|
||||||
},
|
},
|
||||||
|
{ // marked conditional
|
||||||
|
`var.foo ? 1 : 0`,
|
||||||
|
&hcl.EvalContext{
|
||||||
|
Variables: map[string]cty.Value{
|
||||||
|
"var": cty.ObjectVal(map[string]cty.Value{
|
||||||
|
"foo": cty.BoolVal(true),
|
||||||
|
}).Mark("sensitive"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
cty.NumberIntVal(1),
|
||||||
|
0,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
Loading…
Reference in New Issue
Block a user