diag
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Index¶
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeDiagnostic¶
type Diagnostic struct {// Severity indicates the level of the Diagnostic. Currently can be set to// either Error or WarningSeveritySeverity// Summary is a short description of the problem, rendered above location// informationSummarystring// Detail is an optional second message rendered below location information// typically used to communicate a potential fix to the user.Detailstring// AttributePath is a representation of the path starting from the root of// block (resource, datasource, provider) under evaluation by the SDK, to// the attribute that the Diagnostic should be associated to. Terraform will// use this information to render information on where the problem took// place in the user's configuration.//// It is represented with cty.Path, which is a list of steps of either// cty.GetAttrStep (an actual attribute) or cty.IndexStep (a step with Key// of cty.StringVal for map indexes, and cty.NumberVal for list indexes).//// PLEASE NOTE: While cty can support indexing into sets, the SDK and// protocol currently do not. For any Diagnostic related to a schema.TypeSet// or a child of that type, please terminate the path at the schema.TypeSet// and opt for more verbose Summary and Detail to help guide the user.//// Validity of the AttributePath is currently the responsibility of the// developer, Terraform should render the root block (provider, resource,// datasource) in cases where the attribute path is invalid.AttributePathcty.Path}Diagnostic is a contextual message intended at outlining problems in userconfiguration.
It supports multiple levels of severity (Error or Warning), a short Summaryof the problem, an optional longer Detail message that can assist the user infixing the problem, as well as an AttributePath representation whichTerraform uses to indicate where the issue took place in the user'sconfiguration.
A Diagnostic will typically be used to pinpoint a problem with userconfiguration, however it can still be used to present warnings or errorsto the user without any AttributePath set.
func (Diagnostic)Validate¶
func (dDiagnostic) Validate()error
Validate ensures a valid Severity and a non-empty Summary are set.
typeDiagnostics¶
type Diagnostics []Diagnostic
Diagnostics is a collection of Diagnostic.
Developers should append and build the list of diagnostics up until a fatalerror is reached, at which point they should return the Diagnostics to theSDK.
funcErrorf¶
func Errorf(formatstring, a ...interface{})Diagnostics
Errorf creates a Diagnostics with a single Error level Diagnostic entry.The summary is populated by performing a fmt.Sprintf with the suppliedvalues. This returns a single error in a Diagnostics as errors typicallydo not occur in multiples as warnings may.
if unexpectedCondition { return diag.Errorf("unexpected: %s", someValue)}funcFromErr¶
func FromErr(errerror)Diagnostics
FromErr will convert an error into a Diagnostics. This returns Diagnosticsas the most common use case in Go will be handling a single errorreturned from a function.
if err != nil { return diag.FromErr(err)}func (Diagnostics)HasError¶
func (diagsDiagnostics) HasError()bool
HasError returns true is Diagnostics contains an instance ofSeverity == Error.
This helper aims to mimic the go error practices of if err != nil. After anyoperation that returns Diagnostics, check that it HasError and bubble up thestack.