24 lines
513 B
Go
24 lines
513 B
Go
package hcl2template
|
|
|
|
import "github.com/hashicorp/hcl/v2"
|
|
|
|
func warningErrorsToDiags(block *hcl.Block, warnings []string, err error) hcl.Diagnostics {
|
|
var diags hcl.Diagnostics
|
|
|
|
for _, warning := range warnings {
|
|
diags = append(diags, &hcl.Diagnostic{
|
|
Summary: warning,
|
|
Subject: &block.DefRange,
|
|
Severity: hcl.DiagWarning,
|
|
})
|
|
}
|
|
if err != nil {
|
|
diags = append(diags, &hcl.Diagnostic{
|
|
Summary: err.Error(),
|
|
Subject: &block.DefRange,
|
|
Severity: hcl.DiagError,
|
|
})
|
|
}
|
|
return diags
|
|
}
|