Documentation ¶
Overview ¶
Package jsonplan implements methods for outputting a plan in a machine-readable json format
Index ¶
- Constants
- func Marshal(config *configs.Config, p *plans.Plan, sf *statefile.File, ...) ([]byte, error)
- func MarshalForRenderer(p *plans.Plan, schemas *terraform.Schemas) (map[string]Change, []ResourceChange, []ResourceChange, []ResourceAttr, error)
- func MarshalOutputChanges(changes *plans.Changes) (map[string]Change, error)
- func UnmarshalActions(actions []string) plans.Action
- type Change
- type Importing
- type ResourceAttr
- type ResourceChange
Constants ¶
const ( FormatVersion = "1.2" ResourceInstanceReplaceBecauseCannotUpdate = "replace_because_cannot_update" ResourceInstanceReplaceBecauseTainted = "replace_because_tainted" ResourceInstanceReplaceByRequest = "replace_by_request" ResourceInstanceReplaceByTriggers = "replace_by_triggers" ResourceInstanceDeleteBecauseNoResourceConfig = "delete_because_no_resource_config" ResourceInstanceDeleteBecauseWrongRepetition = "delete_because_wrong_repetition" ResourceInstanceDeleteBecauseCountIndex = "delete_because_count_index" ResourceInstanceDeleteBecauseEachKey = "delete_because_each_key" ResourceInstanceDeleteBecauseNoModule = "delete_because_no_module" ResourceInstanceDeleteBecauseNoMoveTarget = "delete_because_no_move_target" ResourceInstanceReadBecauseConfigUnknown = "read_because_config_unknown" ResourceInstanceReadBecauseDependencyPending = "read_because_dependency_pending" ResourceInstanceReadBecauseCheckNested = "read_because_check_nested" )
FormatVersion represents the version of the json format and will be incremented for any change to this format that requires changes to a consuming parser.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶
func Marshal( config *configs.Config, p *plans.Plan, sf *statefile.File, schemas *terraform.Schemas, ) ([]byte, error)
Marshal returns the json encoding of a terraform plan.
func MarshalForRenderer ¶ added in v1.4.0
func MarshalForRenderer( p *plans.Plan, schemas *terraform.Schemas, ) (map[string]Change, []ResourceChange, []ResourceChange, []ResourceAttr, error)
MarshalForRenderer returns the pre-json encoding changes of the requested plan, in a format available to the structured renderer.
This function does a small part of the Marshal function, as it only returns the part of the plan required by the jsonformat.Plan renderer.
func MarshalOutputChanges ¶ added in v1.4.0
MarshalOutputChanges converts the provided internal representation of Changes objects into the structured JSON representation.
This function is referenced directly from the structured renderer tests, to ensure parity between the renderers. It probably shouldn't be used anywhere else.
func UnmarshalActions ¶ added in v1.4.0
UnmarshalActions reverses the actionString function.
Types ¶
type Change ¶ added in v1.4.0
type Change struct { // Actions are the actions that will be taken on the object selected by the // properties below. Valid actions values are: // ["no-op"] // ["create"] // ["read"] // ["update"] // ["delete", "create"] // ["create", "delete"] // ["delete"] // The two "replace" actions are represented in this way to allow callers to // e.g. just scan the list for "delete" to recognize all three situations // where the object will be deleted, allowing for any new deletion // combinations that might be added in future. Actions []string `json:"actions,omitempty"` // Before and After are representations of the object value both before and // after the action. For ["create"] and ["delete"] actions, either "before" // or "after" is unset (respectively). For ["no-op"], the before and after // values are identical. The "after" value will be incomplete if there are // values within it that won't be known until after apply. Before json.RawMessage `json:"before,omitempty"` After json.RawMessage `json:"after,omitempty"` // AfterUnknown is an object value with similar structure to After, but // with all unknown leaf values replaced with true, and all known leaf // values omitted. This can be combined with After to reconstruct a full // value after the action, including values which will only be known after // apply. AfterUnknown json.RawMessage `json:"after_unknown,omitempty"` // BeforeSensitive and AfterSensitive are object values with similar // structure to Before and After, but with all sensitive leaf values // replaced with true, and all non-sensitive leaf values omitted. These // objects should be combined with Before and After to prevent accidental // display of sensitive values in user interfaces. BeforeSensitive json.RawMessage `json:"before_sensitive,omitempty"` AfterSensitive json.RawMessage `json:"after_sensitive,omitempty"` // ReplacePaths is an array of arrays representing a set of paths into the // object value which resulted in the action being "replace". This will be // omitted if the action is not replace, or if no paths caused the // replacement (for example, if the resource was tainted). Each path // consists of one or more steps, each of which will be a number or a // string. ReplacePaths json.RawMessage `json:"replace_paths,omitempty"` // Importing contains the import metadata about this operation. If importing // is present (ie. not null) then the change is an import operation in // addition to anything mentioned in the actions field. The actual contents // of the Importing struct is subject to change, so downstream consumers // should treat any values in here as strictly optional. Importing *Importing `json:"importing,omitempty"` // GeneratedConfig contains any HCL config generated for this resource // during planning as a string. // // If this is populated, then Importing should also be populated but this // might change in the future. However, nNot all Importing changes will // contain generated config. GeneratedConfig string `json:"generated_config,omitempty"` }
Change is the representation of a proposed change for an object.
type Importing ¶ added in v1.5.0
type Importing struct { // The original ID of this resource used to target it as part of planned // import operation. ID string `json:"id,omitempty"` }
Importing is a nested object for the resource import metadata.
type ResourceAttr ¶ added in v1.4.0
type ResourceAttr struct { Resource string `json:"resource"` Attr json.RawMessage `json:"attribute"` }
ResourceAttr contains the address and attribute of an external for the RelevantAttributes in the plan.
type ResourceChange ¶ added in v1.4.0
type ResourceChange struct { // Address is the absolute resource address Address string `json:"address,omitempty"` // PreviousAddress is the absolute address that this resource instance had // at the conclusion of a previous run. // // This will typically be omitted, but will be present if the previous // resource instance was subject to a "moved" block that we handled in the // process of creating this plan. // // Note that this behavior diverges from the internal plan data structure, // where the previous address is set equal to the current address in the // common case, rather than being omitted. PreviousAddress string `json:"previous_address,omitempty"` // ModuleAddress is the module portion of the above address. Omitted if the // instance is in the root module. ModuleAddress string `json:"module_address,omitempty"` // "managed" or "data" Mode string `json:"mode,omitempty"` Type string `json:"type,omitempty"` Name string `json:"name,omitempty"` Index json.RawMessage `json:"index,omitempty"` ProviderName string `json:"provider_name,omitempty"` // "deposed", if set, indicates that this action applies to a "deposed" // object of the given instance rather than to its "current" object. Omitted // for changes to the current object. Deposed string `json:"deposed,omitempty"` // Change describes the change that will be made to this object Change Change `json:"change,omitempty"` // ActionReason is a keyword representing some optional extra context // for why the actions in Change.Actions were chosen. // // This extra detail is only for display purposes, to help a UI layer // present some additional explanation to a human user. The possible // values here might grow and change over time, so any consumer of this // information should be resilient to encountering unrecognized values // and treat them as an unspecified reason. ActionReason string `json:"action_reason,omitempty"` }
ResourceChange is a description of an individual change action that Terraform plans to use to move from the prior state to a new state matching the configuration.
func MarshalResourceChanges ¶ added in v1.4.0
func MarshalResourceChanges(resources []*plans.ResourceInstanceChangeSrc, schemas *terraform.Schemas) ([]ResourceChange, error)
MarshalResourceChanges converts the provided internal representation of ResourceInstanceChangeSrc objects into the public structured JSON changes.
This function is referenced directly from the structured renderer tests, to ensure parity between the renderers. It probably shouldn't be used anywhere else.