Movatterモバイル変換


[0]ホーム

URL:


diag

package
v2.38.1Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2025 License:MPL-2.0Imports:3Imported by:2,628

Details

Repository

github.com/hashicorp/terraform-plugin-sdk

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.

typeSeverity

type Severityint

Severity is an enum type marking the severity level of a Diagnostic

const (ErrorSeverity =iotaWarning)

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp