Merge pull request #427 from hashicorp/pselle/marked-conditionals

Unmark conditional values before checking their truthiness
This commit is contained in:
Pam Selle 2020-12-03 12:22:02 -05:00 committed by GitHub
commit 42b83d915c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -624,6 +624,8 @@ func (e *ConditionalExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostic
return cty.UnknownVal(resultType), diags
}
// Unmark result before testing for truthiness
condResult, _ = condResult.UnmarkDeep()
if condResult.True() {
diags = append(diags, trueDiags...)
if convs[0] != nil {

View File

@ -1582,6 +1582,18 @@ EOT
cty.DynamicVal,
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 {