vendor: update hcl

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2021-02-08 10:18:00 -08:00
parent 42b7e7bc56
commit 98c3ef60e6
6 changed files with 49 additions and 40 deletions

View File

@ -1,6 +1,15 @@
# HCL Changelog
## v2.8.1 (Unreleased)
## v2.8.2 (Unreleased)
### Bugs Fixed
* hclsyntax: Fix panic for marked collection splat. ([#436](https://github.com/hashicorp/hcl/pull/436))
* hclsyntax: Fix panic for marked template loops. ([#437](https://github.com/hashicorp/hcl/pull/437))
* hclsyntax: Fix `for` expression marked conditional.([#438](https://github.com/hashicorp/hcl/pull/438))
* hclsyntax: Mark objects with keys that are sensitive ([#440](https://github.com/hashicorp/hcl/pull/440))
## v2.8.1 (December 17, 2020)
### Bugs Fixed

View File

@ -788,6 +788,7 @@ func (e *ObjectConsExpr) walkChildNodes(w internalWalkFunc) {
func (e *ObjectConsExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) {
var vals map[string]cty.Value
var diags hcl.Diagnostics
var marks []cty.ValueMarks
// This will get set to true if we fail to produce any of our keys,
// either because they are actually unknown or if the evaluation produces
@ -825,18 +826,8 @@ func (e *ObjectConsExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics
continue
}
if key.IsMarked() {
diags = append(diags, &hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Marked value as key",
Detail: "Can't use a marked value as a key.",
Subject: item.ValueExpr.Range().Ptr(),
Expression: item.KeyExpr,
EvalContext: ctx,
})
known = false
continue
}
key, keyMarks := key.Unmark()
marks = append(marks, keyMarks)
var err error
key, err = convert.Convert(key, cty.String)
@ -867,7 +858,7 @@ func (e *ObjectConsExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics
return cty.DynamicVal, diags
}
return cty.ObjectVal(vals), diags
return cty.ObjectVal(vals).WithMarks(marks...), diags
}
func (e *ObjectConsExpr) Range() hcl.Range {
@ -997,6 +988,7 @@ type ForExpr struct {
func (e *ForExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) {
var diags hcl.Diagnostics
var marks []cty.ValueMarks
collVal, collDiags := e.CollExpr.Value(ctx)
diags = append(diags, collDiags...)
@ -1018,7 +1010,8 @@ func (e *ForExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) {
}
// Unmark collection before checking for iterability, because marked
// values cannot be iterated
collVal, marks := collVal.Unmark()
collVal, collMarks := collVal.Unmark()
marks = append(marks, collMarks)
if !collVal.CanIterateElements() {
diags = append(diags, &hcl.Diagnostic{
Severity: hcl.DiagError,
@ -1143,7 +1136,11 @@ func (e *ForExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) {
continue
}
if include.False() {
// Extract and merge marks from the include expression into the
// main set of marks
includeUnmarked, includeMarks := include.Unmark()
marks = append(marks, includeMarks)
if includeUnmarked.False() {
// Skip this element
continue
}
@ -1188,18 +1185,8 @@ func (e *ForExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) {
continue
}
if key.IsMarked() {
diags = append(diags, &hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Invalid object key",
Detail: "Marked values cannot be used as object keys.",
Subject: e.KeyExpr.Range().Ptr(),
Context: &e.SrcRange,
Expression: e.KeyExpr,
EvalContext: childCtx,
})
continue
}
key, keyMarks := key.Unmark()
marks = append(marks, keyMarks)
val, valDiags := e.ValExpr.Value(childCtx)
diags = append(diags, valDiags...)
@ -1239,7 +1226,7 @@ func (e *ForExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) {
}
}
return cty.ObjectVal(vals).WithMarks(marks), diags
return cty.ObjectVal(vals).WithMarks(marks...), diags
} else {
// Producing a tuple
@ -1300,7 +1287,11 @@ func (e *ForExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) {
continue
}
if include.False() {
// Extract and merge marks from the include expression into the
// main set of marks
includeUnmarked, includeMarks := include.Unmark()
marks = append(marks, includeMarks)
if includeUnmarked.False() {
// Skip this element
continue
}
@ -1315,7 +1306,7 @@ func (e *ForExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) {
return cty.DynamicVal, diags
}
return cty.TupleVal(vals).WithMarks(marks), diags
return cty.TupleVal(vals).WithMarks(marks...), diags
}
}
@ -1452,6 +1443,9 @@ func (e *SplatExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) {
return cty.UnknownVal(ty), diags
}
// Unmark the collection, and save the marks to apply to the returned
// collection result
sourceVal, marks := sourceVal.Unmark()
vals := make([]cty.Value, 0, sourceVal.LengthInt())
it := sourceVal.ElementIterator()
if ctx == nil {
@ -1486,9 +1480,9 @@ func (e *SplatExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) {
diags = append(diags, tyDiags...)
return cty.ListValEmpty(ty.ElementType()), diags
}
return cty.ListVal(vals), diags
return cty.ListVal(vals).WithMarks(marks), diags
default:
return cty.TupleVal(vals), diags
return cty.TupleVal(vals).WithMarks(marks), diags
}
}

View File

@ -152,6 +152,8 @@ func (e *TemplateJoinExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnosti
return cty.UnknownVal(cty.String), diags
}
tuple, marks := tuple.Unmark()
allMarks := []cty.ValueMarks{marks}
buf := &bytes.Buffer{}
it := tuple.ElementIterator()
for it.Next() {
@ -171,7 +173,7 @@ func (e *TemplateJoinExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnosti
continue
}
if val.Type() == cty.DynamicPseudoType {
return cty.UnknownVal(cty.String), diags
return cty.UnknownVal(cty.String).WithMarks(marks), diags
}
strVal, err := convert.Convert(val, cty.String)
if err != nil {
@ -189,13 +191,17 @@ func (e *TemplateJoinExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnosti
continue
}
if !val.IsKnown() {
return cty.UnknownVal(cty.String), diags
return cty.UnknownVal(cty.String).WithMarks(marks), diags
}
strVal, strValMarks := strVal.Unmark()
if len(strValMarks) > 0 {
allMarks = append(allMarks, strValMarks)
}
buf.WriteString(strVal.AsString())
}
return cty.StringVal(buf.String()), diags
return cty.StringVal(buf.String()).WithMarks(allMarks...), diags
}
func (e *TemplateJoinExpr) Range() hcl.Range {