github.com/hashicorp/terraform-plugin-sdk@v1.17.2/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 Summary string 29 Detail string 30 } 31 32 type Source struct { 33 Subject *SourceRange 34 Context *SourceRange 35 } 36 37 type FromExpr struct { 38 Expression hcl.Expression 39 EvalContext *hcl.EvalContext 40 }