tfdiags: Unwrap NonFatalError on append

This is a variant of diagnosticsAsError that we use to signal to informed
callers that there might just be warnings inside, but we should also do
the right thing if a caller just appends it to an existing diagnostics
without checking first.
This commit is contained in:
Martin Atkins 2018-05-10 17:22:32 -07:00
parent 8d0bec5728
commit abf0284ca5
1 changed files with 2 additions and 0 deletions

View File

@ -54,6 +54,8 @@ func (diags Diagnostics) Append(new ...interface{}) Diagnostics {
diags = append(diags, ti...) // flatten
case diagnosticsAsError:
diags = diags.Append(ti.Diagnostics) // unwrap
case NonFatalError:
diags = diags.Append(ti.Diagnostics) // unwrap
case hcl.Diagnostics:
for _, hclDiag := range ti {
diags = append(diags, hclDiagnostic{hclDiag})