mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-27 09:21:14 -06:00
126e5f337f
* command/show: adding functions to aid refactoring The planfile -> statefile -> state logic path was getting hard to follow with blurry human eyes. The getPlan... and getState... functions were added to help streamline the logic flow. Continued refactoring may follow. * command/show: use ctx.Config() instead of a config snapshot As originally written, the jsonconfig marshaller was getting an error when loading configs that included one or more modules. It's not clear if that was an error in the function call or in the configloader itself, but as a simpler solution existed I did not dig too far. * command/jsonplan: implement jsonplan.Marshal Split the `config` portion into a discrete package to aid in naming sanity (so we could have for example jsonconfig.Resource instead of jsonplan.ConfigResource) and to enable marshaling the config on it's own.
64 lines
2.3 KiB
Go
64 lines
2.3 KiB
Go
package jsonplan
|
|
|
|
import (
|
|
"github.com/hashicorp/terraform/addrs"
|
|
)
|
|
|
|
// Resource is the representation of a resource in the json plan
|
|
type resource struct {
|
|
// Address is the absolute resource address
|
|
Address string `json:"address,omitempty"`
|
|
|
|
// Mode can be "managed" or "data"
|
|
Mode string `json:"mode,omitempty"`
|
|
|
|
Type string `json:"type,omitempty"`
|
|
Name string `json:"name,omitempty"`
|
|
|
|
// Index is omitted for a resource not using `count` or `for_each`
|
|
Index addrs.InstanceKey `json:"index,omitempty"`
|
|
|
|
// ProviderName allows the property "type" to be interpreted unambiguously
|
|
// in the unusual situation where a provider offers a resource type whose
|
|
// name does not start with its own name, such as the "googlebeta" provider
|
|
// offering "google_compute_instance".
|
|
ProviderName string `json:"provider_name,omitempty"`
|
|
|
|
// SchemaVersion indicates which version of the resource type schema the
|
|
// "values" property conforms to.
|
|
SchemaVersion uint64 `json:"schema_version"`
|
|
|
|
// AttributeValues is the JSON representation of the attribute values of the
|
|
// resource, whose structure depends on the resource type schema. Any
|
|
// unknown values are omitted or set to null, making them indistinguishable
|
|
// from absent values.
|
|
AttributeValues attributeValues `json:"values,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.
|
|
type resourceChange struct {
|
|
// Address is the absolute resource address
|
|
Address string `json:"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 addrs.InstanceKey `json:"index,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 bool `json:"deposed,omitempty"`
|
|
|
|
// Change describes the change that will be made to this object
|
|
Change change `json:"change,omitempty"`
|
|
}
|