kubeform.dev/terraform-backend-sdk@v0.0.0-20220310143633-45f07fe731c5/tfdiags/diagnostic_base.go (about)

     1  package tfdiags
     2  
     3  // diagnosticBase can be embedded in other diagnostic structs to get
     4  // default implementations of Severity and Description. This type also
     5  // has default implementations of Source and FromExpr that return no source
     6  // location or expression-related information, so embedders should generally
     7  // override those method to return more useful results where possible.
     8  type diagnosticBase struct {
     9  	severity Severity
    10  	summary  string
    11  	detail   string
    12  	address  string
    13  }
    14  
    15  func (d diagnosticBase) Severity() Severity {
    16  	return d.severity
    17  }
    18  
    19  func (d diagnosticBase) Description() Description {
    20  	return Description{
    21  		Summary: d.summary,
    22  		Detail:  d.detail,
    23  		Address: d.address,
    24  	}
    25  }
    26  
    27  func (d diagnosticBase) Source() Source {
    28  	return Source{}
    29  }
    30  
    31  func (d diagnosticBase) FromExpr() *FromExpr {
    32  	return nil
    33  }