github.com/iaas-resource-provision/iaas-rpc@v1.0.7-0.20211021023331-ed21f798c408/internal/tfdiags/diagnostic.go (about) 1 package tfdiags 2 3 import ( 4 "github.com/hashicorp/hcl/v2" 5 ) 6 7 type Diagnostic interface { 8 Severity() Severity 9 Description() Description 10 Source() Source 11 12 // FromExpr returns the expression-related context for the diagnostic, if 13 // available. Returns nil if the diagnostic is not related to an 14 // expression evaluation. 15 FromExpr() *FromExpr 16 } 17 18 type Severity rune 19 20 //go:generate go run golang.org/x/tools/cmd/stringer -type=Severity 21 22 const ( 23 Error Severity = 'E' 24 Warning Severity = 'W' 25 ) 26 27 type Description struct { 28 Address string 29 Summary string 30 Detail string 31 } 32 33 type Source struct { 34 Subject *SourceRange 35 Context *SourceRange 36 } 37 38 type FromExpr struct { 39 Expression hcl.Expression 40 EvalContext *hcl.EvalContext 41 }