diag

package
v2.0.0-beta.53 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MPL-2.0 Imports: 1 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Diagnostic

type Diagnostic interface {
	// Severity returns the desired level of feedback for the diagnostic.
	Severity() Severity

	// Summary is a short description for the diagnostic.
	//
	// Typically this is implemented as a title, such as "Invalid Resource Name",
	// or single line sentence.
	Summary() string

	// Detail is a long description for the diagnostic.
	//
	// This should contain all relevant information about why the diagnostic
	// was generated and if applicable, ways to prevent the diagnostic. It
	// should generally be written and formatted for human consumption by
	// practitioners or provider developers.
	Detail() string

	// Equal returns true if the other diagnostic is wholly equivalent.
	Equal(Diagnostic) bool
}

type DiagnosticWithErr

type DiagnosticWithErr interface {
	Diagnostic

	Err() error
}

type Diagnostics

type Diagnostics []Diagnostic

Diagnostics represents a collection of diagnostics.

While this collection is ordered, the order is not guaranteed as reliable or consistent.

func (Diagnostics) AddError

func (diags Diagnostics) AddError(summary string, detail string) Diagnostics

AddError adds a generic error diagnostic to the collection.

func (Diagnostics) AddSimpleError

func (diags Diagnostics) AddSimpleError(err error) Diagnostics

func (Diagnostics) AddWarning

func (diags Diagnostics) AddWarning(summary string, detail string) Diagnostics

AddWarning adds a generic warning diagnostic to the collection.

func (Diagnostics) Append

func (diags Diagnostics) Append(in ...Diagnostic) Diagnostics

Append adds non-empty and non-duplicate diagnostics to the collection.

func (Diagnostics) Contains

func (diags Diagnostics) Contains(in Diagnostic) bool

Contains returns true if the collection contains an equal Diagnostic.

func (Diagnostics) Count

func (diags Diagnostics) Count() int

func (Diagnostics) Equal

func (diags Diagnostics) Equal(other Diagnostics) bool

Equal returns true if all given diagnostics are equivalent in order and content, based on the underlying (Diagnostic).Equal() method of each.

func (Diagnostics) Errors

func (diags Diagnostics) Errors() Diagnostics

Errors returns all the Diagnostic in Diagnostics that are SeverityError.

func (Diagnostics) ErrorsCount

func (diags Diagnostics) ErrorsCount() int

ErrorsCount returns the number of Diagnostic in Diagnostics that are SeverityError.

func (Diagnostics) HasError

func (diags Diagnostics) HasError() bool

HasError returns true if the collection has an error severity Diagnostic.

func (Diagnostics) Warnings

func (diags Diagnostics) Warnings() Diagnostics

Warnings returns all the Diagnostic in Diagnostics that are SeverityWarning.

func (Diagnostics) WarningsCount

func (diags Diagnostics) WarningsCount() int

WarningsCount returns the number of Diagnostic in Diagnostics that are SeverityWarning.

type ErrorDiagnostic

type ErrorDiagnostic struct {
	// contains filtered or unexported fields
}

ErrorDiagnostic is a generic diagnostic with error severity.

func NewErrorDiagnostic

func NewErrorDiagnostic(summary string, detail string) ErrorDiagnostic

NewErrorDiagnostic returns a new error severity diagnostic with the given summary and detail.

func (ErrorDiagnostic) Detail

func (d ErrorDiagnostic) Detail() string

Detail returns the diagnostic detail.

func (ErrorDiagnostic) Equal

func (d ErrorDiagnostic) Equal(other Diagnostic) bool

Equal returns true if the other diagnostic is wholly equivalent.

func (ErrorDiagnostic) Severity

func (d ErrorDiagnostic) Severity() Severity

Severity returns the diagnostic severity.

func (ErrorDiagnostic) Summary

func (d ErrorDiagnostic) Summary() string

Summary returns the diagnostic summary.

type NativeErrorDiagnostic

type NativeErrorDiagnostic struct {
	// contains filtered or unexported fields
}

NativeErrorDiagnostic is a diagnostic with error severity which wraps a Go error.

func NewNativeErrorDiagnostic

func NewNativeErrorDiagnostic(err error) NativeErrorDiagnostic

NewNativeErrorDiagnostic returns a new error severity diagnostic with the given error.

func (NativeErrorDiagnostic) Detail

func (d NativeErrorDiagnostic) Detail() string

Detail returns the diagnostic detail.

func (NativeErrorDiagnostic) Equal

func (d NativeErrorDiagnostic) Equal(other Diagnostic) bool

Equal returns true if the other diagnostic is wholly equivalent.

func (NativeErrorDiagnostic) Err

func (d NativeErrorDiagnostic) Err() error

func (NativeErrorDiagnostic) GoString

func (d NativeErrorDiagnostic) GoString() string

func (NativeErrorDiagnostic) Severity

func (d NativeErrorDiagnostic) Severity() Severity

Severity returns the diagnostic severity.

func (NativeErrorDiagnostic) Summary

func (d NativeErrorDiagnostic) Summary() string

Summary returns the diagnostic summary.

type Severity

type Severity int

Severity represents the level of feedback for a diagnostic.

Each severity implies behavior changes for the feedback and potentially the further execution of logic.

const (
	// SeverityInvalid represents an undefined severity.
	//
	// It should not be used directly in implementations.
	SeverityInvalid Severity = 0

	// SeverityError represents a terminating condition.
	//
	// This can cause a failing status code for command line programs.
	//
	// Most implementations should return early when encountering an error.
	SeverityError Severity = 1

	// SeverityWarning represents a condition with explicit feedback.
	//
	// Most implementations should continue when encountering a warning.
	SeverityWarning Severity = 2
)

func (Severity) String

func (s Severity) String() string

String returns a textual representation of the severity.

type WarningDiagnostic

type WarningDiagnostic struct {
	// contains filtered or unexported fields
}

WarningDiagnostic is a generic diagnostic with warning severity.

func NewWarningDiagnostic

func NewWarningDiagnostic(summary string, detail string) WarningDiagnostic

NewWarningDiagnostic returns a new warning severity diagnostic with the given summary and detail.

func (WarningDiagnostic) Detail

func (d WarningDiagnostic) Detail() string

Detail returns the diagnostic detail.

func (WarningDiagnostic) Equal

func (d WarningDiagnostic) Equal(other Diagnostic) bool

Equal returns true if the other diagnostic is wholly equivalent.

func (WarningDiagnostic) Severity

func (d WarningDiagnostic) Severity() Severity

Severity returns the diagnostic severity.

func (WarningDiagnostic) Summary

func (d WarningDiagnostic) Summary() string

Summary returns the diagnostic summary.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL