Skip to content

Commit

Permalink
hclsyntax: Test for interpolating from marked map
Browse files Browse the repository at this point in the history
  • Loading branch information
alisdair committed Sep 24, 2020
1 parent 35ad930 commit 8eccdca
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions hclsyntax/expression_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ trim`,
`hello%{ if false } ${target}%{ endif }`,
&hcl.EvalContext{
Variables: map[string]cty.Value{
"target": cty.StringVal("world").WithMarks(cty.NewValueMarks("sensitive")),
"target": cty.StringVal("world").Mark("sensitive"),
},
},
cty.StringVal("hello"),
Expand All @@ -297,13 +297,25 @@ trim`,
`${greeting} ${target}`,
&hcl.EvalContext{
Variables: map[string]cty.Value{
"greeting": cty.StringVal("hello").WithMarks(cty.NewValueMarks("english")),
"target": cty.StringVal("world").WithMarks(cty.NewValueMarks("sensitive")),
"greeting": cty.StringVal("hello").Mark("english"),
"target": cty.StringVal("world").Mark("sensitive"),
},
},
cty.StringVal("hello world").WithMarks(cty.NewValueMarks("english", "sensitive")),
0,
},
{ // can use marks by traversing complex values
`Authenticate with "${secrets.passphrase}"`,
&hcl.EvalContext{
Variables: map[string]cty.Value{
"secrets": cty.MapVal(map[string]cty.Value{
"passphrase": cty.StringVal("my voice is my passport").Mark("sensitive"),
}).Mark("sensitive"),
},
},
cty.StringVal(`Authenticate with "my voice is my passport"`).WithMarks(cty.NewValueMarks("sensitive")),
0,
},
}

for _, test := range tests {
Expand Down

0 comments on commit 8eccdca

Please # to comment.