Documentation ¶
Index ¶
- Constants
- type ChangeAction
- type ChangeReason
- type ChangeSummary
- type Diagnostic
- type DiagnosticExpressionValue
- type DiagnosticFunctionCall
- type DiagnosticRange
- type DiagnosticSnippet
- type Function
- type FunctionParam
- type Hook
- func NewApplyComplete(addr addrs.AbsResourceInstance, action plans.Action, idKey, idValue string, ...) Hook
- func NewApplyErrored(addr addrs.AbsResourceInstance, action plans.Action, elapsed time.Duration) Hook
- func NewApplyProgress(addr addrs.AbsResourceInstance, action plans.Action, elapsed time.Duration) Hook
- func NewApplyStart(addr addrs.AbsResourceInstance, action plans.Action, idKey string, ...) Hook
- func NewProvisionComplete(addr addrs.AbsResourceInstance, provisioner string) Hook
- func NewProvisionErrored(addr addrs.AbsResourceInstance, provisioner string) Hook
- func NewProvisionProgress(addr addrs.AbsResourceInstance, provisioner string, output string) Hook
- func NewProvisionStart(addr addrs.AbsResourceInstance, provisioner string) Hook
- func NewRefreshComplete(addr addrs.AbsResourceInstance, idKey, idValue string) Hook
- func NewRefreshStart(addr addrs.AbsResourceInstance, idKey, idValue string) Hook
- type Importing
- type MessageType
- type Operation
- type Output
- type Outputs
- type Pos
- type ResourceAddr
- type ResourceInstanceChange
- type TestFailedResource
- type TestFatalInterrupt
- type TestFileCleanup
- type TestFileStatus
- type TestRunStatus
- type TestStatus
- type TestSuiteAbstract
- type TestSuiteSummary
Constants ¶
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 ¶
type ChangeAction string
const ( ActionNoOp ChangeAction = "noop" ActionMove ChangeAction = "move" ActionCreate ChangeAction = "create" ActionRead ChangeAction = "read" ActionUpdate ChangeAction = "update" ActionReplace ChangeAction = "replace" ActionDelete ChangeAction = "delete" ActionImport ChangeAction = "import" )
type ChangeReason ¶
type ChangeReason string
const ( ReasonNone ChangeReason = "" ReasonTainted ChangeReason = "tainted" ReasonRequested ChangeReason = "requested" ReasonReplaceTriggeredBy ChangeReason = "replace_triggered_by" ReasonCannotUpdate ChangeReason = "cannot_update" ReasonUnknown ChangeReason = "unknown" ReasonDeleteBecauseNoResourceConfig ChangeReason = "delete_because_no_resource_config" ReasonDeleteBecauseWrongRepetition ChangeReason = "delete_because_wrong_repetition" ReasonDeleteBecauseCountIndex ChangeReason = "delete_because_count_index" ReasonDeleteBecauseEachKey ChangeReason = "delete_because_each_key" ReasonDeleteBecauseNoModule ChangeReason = "delete_because_no_module" ReasonDeleteBecauseNoMoveTarget ChangeReason = "delete_because_no_move_target" ReasonReadBecauseConfigUnknown ChangeReason = "read_because_config_unknown" ReasonReadBecauseDependencyPending ChangeReason = "read_because_dependency_pending" ReasonReadBecauseCheckNested ChangeReason = "read_because_check_nested" )
type ChangeSummary ¶
type ChangeSummary struct { Add int `json:"add"` Change int `json:"change"` Import int `json:"import"` Remove int `json:"remove"` Operation Operation `json:"operation"` }
func (*ChangeSummary) String ¶
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 DiagnosticFunctionCall ¶
type DiagnosticFunctionCall struct { // CalledAs is the full name that was used to call this function, // potentially including namespace prefixes if the function does not belong // to the default function namespace. CalledAs string `json:"called_as"` // Signature is a description of the signature of the function that was // called, if any. Might be omitted if we're reporting that a call failed // because the given function name isn't known, for example. Signature *Function `json:"signature,omitempty"` }
DiagnosticFunctionCall represents a function call whose information is being included as part of a diagnostic snippet.
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 OpenTofu 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"` // FunctionCall is information about a function call whose failure is // being reported by this diagnostic, if any. FunctionCall *DiagnosticFunctionCall `json:"function_call,omitempty"` }
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 Function ¶
type Function struct { // Name is the leaf name of the function, without any namespace prefix. Name string `json:"name"` Params []FunctionParam `json:"params"` VariadicParam *FunctionParam `json:"variadic_param,omitempty"` // ReturnType is type constraint which is a static approximation of the // possibly-dynamic return type of the function. ReturnType json.RawMessage `json:"return_type"` Description string `json:"description,omitempty"` DescriptionKind string `json:"description_kind,omitempty"` }
Function is a description of the JSON representation of the signature of a function callable from the OpenTofu language.
type FunctionParam ¶
type FunctionParam struct { // Name is a name for the function which is used primarily for // documentation purposes, because function arguments are positional // and therefore don't appear directly in configuration source code. Name string `json:"name"` // Type is a type constraint which is a static approximation of the // possibly-dynamic type of the parameter. Particular functions may // have additional requirements that a type constraint alone cannot // represent. Type json.RawMessage `json:"type"` Description string `json:"description,omitempty"` DescriptionKind string `json:"description_kind,omitempty"` }
FunctionParam represents a single parameter to a function, as represented by type Function.
type Hook ¶
type Hook interface { HookType() MessageType String() string }
func NewApplyComplete ¶
func NewApplyErrored ¶
func NewApplyProgress ¶
func NewApplyStart ¶
func NewProvisionComplete ¶
func NewProvisionComplete(addr addrs.AbsResourceInstance, provisioner string) Hook
func NewProvisionErrored ¶
func NewProvisionErrored(addr addrs.AbsResourceInstance, provisioner string) Hook
func NewProvisionProgress ¶
func NewProvisionProgress(addr addrs.AbsResourceInstance, provisioner string, output string) Hook
func NewProvisionStart ¶
func NewProvisionStart(addr addrs.AbsResourceInstance, provisioner string) Hook
func NewRefreshComplete ¶
func NewRefreshComplete(addr addrs.AbsResourceInstance, idKey, idValue string) Hook
func NewRefreshStart ¶
func NewRefreshStart(addr addrs.AbsResourceInstance, idKey, idValue string) Hook
type Importing ¶
type Importing struct {
ID string `json:"id,omitempty"`
}
Importing contains metadata about a resource change that includes an import action.
Every field in here should be treated as optional as future versions do not make a guarantee that they will retain the format of this change.
Consumers should be capable of rendering/parsing the Importing struct even if it does not have the ID field set.
type MessageType ¶
type MessageType string
const ( // Generic messages MessageVersion MessageType = "version" MessageLog MessageType = "log" MessageDiagnostic MessageType = "diagnostic" // Operation results MessageResourceDrift MessageType = "resource_drift" 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" // Test messages MessageTestAbstract MessageType = "test_abstract" MessageTestFile MessageType = "test_file" MessageTestRun MessageType = "test_run" MessageTestPlan MessageType = "test_plan" MessageTestState MessageType = "test_state" MessageTestSummary MessageType = "test_summary" MessageTestCleanup MessageType = "test_cleanup" MessageTestInterrupt MessageType = "test_interrupt" )
type Output ¶
type Output struct { Sensitive bool `json:"sensitive"` Type json.RawMessage `json:"type,omitempty"` Value json.RawMessage `json:"value,omitempty"` Action ChangeAction `json:"action,omitempty"` }
type Outputs ¶
func OutputsFromChanges ¶
func OutputsFromChanges(changes []*plans.OutputChangeSrc) Outputs
func OutputsFromMap ¶
func OutputsFromMap(outputValues map[string]*states.OutputValue) (Outputs, tfdiags.Diagnostics)
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 ¶
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 ¶
type ResourceInstanceChange struct { Resource ResourceAddr `json:"resource"` PreviousResource *ResourceAddr `json:"previous_resource,omitempty"` Action ChangeAction `json:"action"` Reason ChangeReason `json:"reason,omitempty"` Importing *Importing `json:"importing,omitempty"` GeneratedConfig string `json:"generated_config,omitempty"` }
func NewResourceInstanceChange ¶
func NewResourceInstanceChange(change *plans.ResourceInstanceChangeSrc) *ResourceInstanceChange
func (*ResourceInstanceChange) String ¶
func (c *ResourceInstanceChange) String() string
type TestFailedResource ¶
type TestFatalInterrupt ¶
type TestFatalInterrupt struct { State []TestFailedResource `json:"state,omitempty"` States map[string][]TestFailedResource `json:"states,omitempty"` Planned []string `json:"planned,omitempty"` }
type TestFileCleanup ¶
type TestFileCleanup struct {
FailedResources []TestFailedResource `json:"failed_resources"`
}
type TestFileStatus ¶
type TestFileStatus struct { Path string `json:"path"` Status TestStatus `json:"status"` }
type TestRunStatus ¶
type TestRunStatus struct { Path string `json:"path"` Run string `json:"run"` Status TestStatus `json:"status"` }
type TestStatus ¶
type TestStatus string
func ToTestStatus ¶
func ToTestStatus(status moduletest.Status) TestStatus
type TestSuiteAbstract ¶
type TestSuiteSummary ¶
type TestSuiteSummary struct { Status TestStatus `json:"status"` Passed int `json:"passed"` Failed int `json:"failed"` Errored int `json:"errored"` Skipped int `json:"skipped"` }