Documentation
¶
Overview ¶
Package jsonentities contains the entities for representing a few common resources used around the json* packages.
Index ¶
- Constants
- func FromJsonViewsOutput(output Output) structured.Change
- type ChangeAction
- type ChangeReason
- type Diagnostic
- type DiagnosticExpressionValue
- type DiagnosticFunctionCall
- type DiagnosticRange
- type DiagnosticSnippet
- type Function
- type FunctionParam
- type Importing
- type Output
- type Outputs
- type Pos
- type ResourceAddr
- type ResourceInstanceChange
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 ¶
func FromJsonViewsOutput ¶
func FromJsonViewsOutput(output Output) structured.Change
FromJsonViewsOutput unmarshals the raw values in the viewsjson.Output structs into generic interface{} types that can be reasoned about.
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" ActionForget ChangeAction = "remove" ActionOpen ChangeAction = "open" )
func ParseChangeAction ¶
func ParseChangeAction(action plans.Action) ChangeAction
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" ReasonDeleteBecauseEnabledFalse ChangeReason = "delete_because_enabled_false" 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" ReasonForgotBecauseLifecycleDestroyInConfig ChangeReason = "forgot_because_lifecycle_destroy_in_config" ReasonForgotBecauseLifecycleDestroyInState ChangeReason = "forgot_because_lifecycle_destroy_in_state" )
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"`
Difference *jsonplan.Change `json:"difference,omitempty"`
}
func NewDiagnostic ¶
func NewDiagnostic(diag tfdiags.Diagnostic, sources map[string]*hcl.File) *Diagnostic
NewDiagnostic takes a tfdiags.Diagnostic and a map of configuration sources, and returns a Diagnostic object as a "UI-flavored" representation of the diagnostic.
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 Ghoten 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 Ghoten 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 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 Output ¶
type Output struct {
Sensitive bool `json:"sensitive"`
Deprecated string `json:"deprecated,omitempty"`
Type json.RawMessage `json:"type,omitempty"`
Value json.RawMessage `json:"value,omitempty"`
Action ChangeAction `json:"action,omitempty"`
}
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"`
}
func NewResourceAddr ¶
func NewResourceAddr(addr addrs.AbsResourceInstance) ResourceAddr
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