json

package
Version: v0.15.3 Latest Latest
Warning

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

Go to latest
Published: May 6, 2021 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DiagnosticSeverityUnknown = "unknown"
	DiagnosticSeverityError   = "error"
	DiagnosticSeverityWarning = "warning"
)

These severities map to the tfdiags.Severity values, plus an explicit unknown in case that enum grows without us noticing here.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeAction added in v0.15.2

type ChangeAction string
const (
	ActionNoOp    ChangeAction = "noop"
	ActionCreate  ChangeAction = "create"
	ActionRead    ChangeAction = "read"
	ActionUpdate  ChangeAction = "update"
	ActionReplace ChangeAction = "replace"
	ActionDelete  ChangeAction = "delete"
)

type ChangeReason added in v0.15.2

type ChangeReason string
const (
	ReasonNone         ChangeReason = ""
	ReasonTainted      ChangeReason = "tainted"
	ReasonRequested    ChangeReason = "requested"
	ReasonCannotUpdate ChangeReason = "cannot_update"
	ReasonUnknown      ChangeReason = "unknown"
)

type ChangeSummary added in v0.15.2

type ChangeSummary struct {
	Add       int       `json:"add"`
	Change    int       `json:"change"`
	Remove    int       `json:"remove"`
	Operation Operation `json:"operation"`
}

func (*ChangeSummary) String added in v0.15.2

func (cs *ChangeSummary) String() string

The summary strings for apply and plan are accidentally a public interface used by Terraform Cloud and Terraform Enterprise, so the exact formats of these strings are important.

type Diagnostic

type Diagnostic struct {
	Severity string             `json:"severity"`
	Summary  string             `json:"summary"`
	Detail   string             `json:"detail"`
	Address  string             `json:"address,omitempty"`
	Range    *DiagnosticRange   `json:"range,omitempty"`
	Snippet  *DiagnosticSnippet `json:"snippet,omitempty"`
}

Diagnostic represents any tfdiags.Diagnostic value. The simplest form has just a severity, single line summary, and optional detail. If there is more information about the source of the diagnostic, this is represented in the range field.

func NewDiagnostic

func NewDiagnostic(diag tfdiags.Diagnostic, sources map[string][]byte) *Diagnostic

NewDiagnostic takes a tfdiags.Diagnostic and a map of configuration sources, and returns a Diagnostic struct.

type DiagnosticExpressionValue

type DiagnosticExpressionValue struct {
	Traversal string `json:"traversal"`
	Statement string `json:"statement"`
}

DiagnosticExpressionValue represents an HCL traversal string (e.g. "var.foo") and a statement about its value while the expression was evaluated (e.g. "is a string", "will be known only after apply"). These are intended to help the consumer diagnose why an expression caused a diagnostic to be emitted.

type DiagnosticRange

type DiagnosticRange struct {
	Filename string `json:"filename"`
	Start    Pos    `json:"start"`
	End      Pos    `json:"end"`
}

DiagnosticRange represents the filename and position of the diagnostic subject. This defines the range of the source to be highlighted in the output. Note that the snippet may include additional surrounding source code if the diagnostic has a context range.

The Start position is inclusive, and the End position is exclusive. Exact positions are intended for highlighting for human interpretation only and are subject to change.

type DiagnosticSnippet

type DiagnosticSnippet struct {
	// Context is derived from HCL's hcled.ContextString output. This gives a
	// high-level summary of the root context of the diagnostic: for example,
	// the resource block in which an expression causes an error.
	Context *string `json:"context"`

	// Code is a possibly-multi-line string of Terraform configuration, which
	// includes both the diagnostic source and any relevant context as defined
	// by the diagnostic.
	Code string `json:"code"`

	// StartLine is the line number in the source file for the first line of
	// the snippet code block. This is not necessarily the same as the value of
	// Range.Start.Line, as it is possible to have zero or more lines of
	// context source code before the diagnostic range starts.
	StartLine int `json:"start_line"`

	// HighlightStartOffset is the character offset into Code at which the
	// diagnostic source range starts, which ought to be highlighted as such by
	// the consumer of this data.
	HighlightStartOffset int `json:"highlight_start_offset"`

	// HighlightEndOffset is the character offset into Code at which the
	// diagnostic source range ends.
	HighlightEndOffset int `json:"highlight_end_offset"`

	// Values is a sorted slice of expression values which may be useful in
	// understanding the source of an error in a complex expression.
	Values []DiagnosticExpressionValue `json:"values"`
}

DiagnosticSnippet represents source code information about the diagnostic. It is possible for a diagnostic to have a source (and therefore a range) but no source code can be found. In this case, the range field will be present and the snippet field will not.

type Hook added in v0.15.2

type Hook interface {
	HookType() MessageType
	String() string
}

func NewApplyComplete added in v0.15.2

func NewApplyComplete(addr addrs.AbsResourceInstance, action plans.Action, idKey, idValue string, elapsed time.Duration) Hook

func NewApplyErrored added in v0.15.2

func NewApplyErrored(addr addrs.AbsResourceInstance, action plans.Action, elapsed time.Duration) Hook

func NewApplyProgress added in v0.15.2

func NewApplyProgress(addr addrs.AbsResourceInstance, action plans.Action, elapsed time.Duration) Hook

func NewApplyStart added in v0.15.2

func NewApplyStart(addr addrs.AbsResourceInstance, action plans.Action, idKey string, idValue string) Hook

func NewProvisionComplete added in v0.15.2

func NewProvisionComplete(addr addrs.AbsResourceInstance, provisioner string) Hook

func NewProvisionErrored added in v0.15.2

func NewProvisionErrored(addr addrs.AbsResourceInstance, provisioner string) Hook

func NewProvisionProgress added in v0.15.2

func NewProvisionProgress(addr addrs.AbsResourceInstance, provisioner string, output string) Hook

func NewProvisionStart added in v0.15.2

func NewProvisionStart(addr addrs.AbsResourceInstance, provisioner string) Hook

func NewRefreshComplete added in v0.15.2

func NewRefreshComplete(addr addrs.AbsResourceInstance, idKey, idValue string) Hook

func NewRefreshStart added in v0.15.2

func NewRefreshStart(addr addrs.AbsResourceInstance, idKey, idValue string) Hook

type MessageType added in v0.15.2

type MessageType string
const (
	// Generic messages
	MessageVersion    MessageType = "version"
	MessageLog        MessageType = "log"
	MessageDiagnostic MessageType = "diagnostic"

	// Operation results
	MessagePlannedChange MessageType = "planned_change"
	MessageChangeSummary MessageType = "change_summary"
	MessageOutputs       MessageType = "outputs"

	// Hook-driven messages
	MessageApplyStart        MessageType = "apply_start"
	MessageApplyProgress     MessageType = "apply_progress"
	MessageApplyComplete     MessageType = "apply_complete"
	MessageApplyErrored      MessageType = "apply_errored"
	MessageProvisionStart    MessageType = "provision_start"
	MessageProvisionProgress MessageType = "provision_progress"
	MessageProvisionComplete MessageType = "provision_complete"
	MessageProvisionErrored  MessageType = "provision_errored"
	MessageRefreshStart      MessageType = "refresh_start"
	MessageRefreshComplete   MessageType = "refresh_complete"
)

type Operation added in v0.15.2

type Operation string
const (
	OperationApplied   Operation = "apply"
	OperationDestroyed Operation = "destroy"
	OperationPlanned   Operation = "plan"
)

type Output added in v0.15.2

type Output struct {
	Sensitive bool            `json:"sensitive"`
	Type      json.RawMessage `json:"type"`
	Value     json.RawMessage `json:"value"`
}

type Outputs added in v0.15.2

type Outputs map[string]Output

func OutputsFromMap added in v0.15.2

func OutputsFromMap(outputValues map[string]*states.OutputValue) (Outputs, tfdiags.Diagnostics)

func (Outputs) String added in v0.15.2

func (o Outputs) String() string

type Pos

type Pos struct {
	// Line is a one-based count for the line in the indicated file.
	Line int `json:"line"`

	// Column is a one-based count of Unicode characters from the start of the line.
	Column int `json:"column"`

	// Byte is a zero-based offset into the indicated file.
	Byte int `json:"byte"`
}

Pos represents a position in the source code.

type ResourceAddr added in v0.15.2

type ResourceAddr struct {
	Addr            string                  `json:"addr"`
	Module          string                  `json:"module"`
	Resource        string                  `json:"resource"`
	ImpliedProvider string                  `json:"implied_provider"`
	ResourceType    string                  `json:"resource_type"`
	ResourceName    string                  `json:"resource_name"`
	ResourceKey     ctyjson.SimpleJSONValue `json:"resource_key"`
}

type ResourceInstanceChange added in v0.15.2

type ResourceInstanceChange struct {
	Resource ResourceAddr `json:"resource"`
	Action   ChangeAction `json:"action"`
	Reason   ChangeReason `json:"reason,omitempty"`
}

func NewResourceInstanceChange added in v0.15.2

func NewResourceInstanceChange(change *plans.ResourceInstanceChangeSrc) *ResourceInstanceChange

func (*ResourceInstanceChange) String added in v0.15.2

func (c *ResourceInstanceChange) String() string

Jump to

Keyboard shortcuts

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