terraform: github.com/hashicorp/terraform/terraform Index | Files

package terraform

import "github.com/hashicorp/terraform/terraform"

Index

Package Files

context.go context_components.go context_graph_type.go context_import.go debug.go diff.go edge_destroy.go eval.go eval_apply.go eval_check_prevent_destroy.go eval_context.go eval_context_builtin.go eval_context_mock.go eval_count.go eval_count_boundary.go eval_count_computed.go eval_diff.go eval_error.go eval_filter.go eval_filter_operation.go eval_if.go eval_import_state.go eval_interpolate.go eval_local.go eval_noop.go eval_output.go eval_provider.go eval_provisioner.go eval_read_data.go eval_refresh.go eval_resource.go eval_sequence.go eval_state.go eval_validate.go eval_validate_selfref.go eval_variable.go evaltree_provider.go features.go graph.go graph_builder.go graph_builder_apply.go graph_builder_destroy_plan.go graph_builder_import.go graph_builder_input.go graph_builder_plan.go graph_builder_refresh.go graph_builder_validate.go graph_dot.go graph_interface_subgraph.go graph_walk.go graph_walk_context.go graph_walk_operation.go graphtype_string.go hook.go hook_mock.go hook_stop.go instancetype.go instancetype_string.go interpolate.go module_dependencies.go node_count_boundary.go node_data_destroy.go node_data_refresh.go node_local.go node_module_removed.go node_module_variable.go node_output.go node_output_orphan.go node_provider.go node_provider_abstract.go node_provider_disabled.go node_provisioner.go node_resource_abstract.go node_resource_abstract_count.go node_resource_apply.go node_resource_destroy.go node_resource_plan.go node_resource_plan_destroy.go node_resource_plan_instance.go node_resource_plan_orphan.go node_resource_refresh.go node_resource_validate.go node_root_variable.go path.go plan.go resource.go resource_address.go resource_provider.go resource_provider_mock.go resource_provisioner.go resource_provisioner_mock.go schemas.go semantics.go state.go state_add.go state_filter.go state_upgrade_v1_to_v2.go state_upgrade_v2_to_v3.go state_v1.go testing.go transform.go transform_attach_config_provider.go transform_attach_config_resource.go transform_attach_state.go transform_config.go transform_config_flat.go transform_config_old.go transform_count_boundary.go transform_deposed.go transform_destroy_cbd.go transform_destroy_edge.go transform_diff.go transform_expand.go transform_import_provider.go transform_import_state.go transform_local.go transform_module_variable.go transform_orphan_count.go transform_orphan_output.go transform_orphan_resource.go transform_output.go transform_provider.go transform_provisioner.go transform_reference.go transform_removed_modules.go transform_resource_count.go transform_root.go transform_state.go transform_targets.go transform_transitive_reduction.go transform_variable.go transform_vertex.go ui_input.go ui_input_mock.go ui_input_prefix.go ui_output.go ui_output_callback.go ui_output_mock.go ui_output_provisioner.go user_agent.go util.go variables.go version.go version_required.go walkoperation_string.go

Constants

const RootModuleName = "root"

RootModuleName is the name given to the root module implicitly.

const (
    // StateVersion is the current version for our state file
    StateVersion = 3
)
const (
    // VarEnvPrefix is the prefix of variables that are read from
    // the environment to set variables here.
    VarEnvPrefix = "TF_VAR_"
)

Variables

var ErrNoState = errors.New("no state")

ErrNoState is returned by ReadState when the io.Reader contains no data

var GraphTypeMap = map[string]GraphType{
    "apply":        GraphTypeApply,
    "input":        GraphTypeInput,
    "plan":         GraphTypePlan,
    "plan-destroy": GraphTypePlanDestroy,
    "refresh":      GraphTypeRefresh,
    "legacy":       GraphTypeLegacy,
    "validate":     GraphTypeValidate,
}

GraphTypeMap is a mapping of human-readable string to GraphType. This is useful to use as the mechanism for human input for configurable graph types.

var RootModulePath = []string{RootModuleName}

RootModulePath is the path for the root module.

func CheckRequiredVersion Uses

func CheckRequiredVersion(m *module.Tree) error

CheckRequiredVersion verifies that any version requirements specified by the configuration are met.

This checks the root module as well as any additional version requirements from child modules.

This is tested in context_test.go.

func CheckStateVersion Uses

func CheckStateVersion(state *State) error

StateCompatible returns an error if the state is not compatible with the current version of terraform.

func CloseDebugInfo Uses

func CloseDebugInfo() error

CloseDebugInfo is the exported interface to Close the debug info handler. The debug handler needs to be closed before program exit, so we export this function to be deferred in the appropriate entrypoint for our executable.

func Eval Uses

func Eval(n EvalNode, ctx EvalContext) (interface{}, error)

Eval evaluates the given EvalNode with the given context, properly evaluating all args in the correct order.

func EvalRaw Uses

func EvalRaw(n EvalNode, ctx EvalContext) (interface{}, error)

EvalRaw is like Eval except that it returns all errors, even if they signal something normal such as EvalEarlyExitError.

func GraphDot Uses

func GraphDot(g *Graph, opts *dag.DotOpts) (string, error)

GraphDot returns the dot formatting of a visual representation of the given Terraform graph.

func ModuleTreeDependencies Uses

func ModuleTreeDependencies(root *module.Tree, state *State) *moduledeps.Module

ModuleTreeDependencies returns the dependencies of the tree of modules described by the given configuration tree and state.

Both configuration and state are required because there can be resources implied by instances in the state that no longer exist in config.

This function will panic if any invalid version constraint strings are present in the configuration. This is guaranteed not to happen for any configuration that has passed a call to Config.Validate().

func ParseResourceIndex Uses

func ParseResourceIndex(s string) (int, error)

func ParseResourcePath Uses

func ParseResourcePath(s string) []string

func PathCacheKey Uses

func PathCacheKey(path []string) string

PathCacheKey returns a cache key for a module path.

func ProviderHasDataSource Uses

func ProviderHasDataSource(p ResourceProvider, n string) bool

func ProviderHasResource Uses

func ProviderHasResource(p ResourceProvider, n string) bool

func ReadStateV1 Uses

func ReadStateV1(jsonBytes []byte) (*stateV1, error)

func ReferenceFromInterpolatedVar Uses

func ReferenceFromInterpolatedVar(v config.InterpolatedVariable) []string

ReferenceFromInterpolatedVar returns the reference from this variable, or an empty string if there is no reference.

func ReferenceModulePath Uses

func ReferenceModulePath(p []string) []string

Returns the reference name for a module path. The path "foo" would return "module.foo". If this is a deeply nested module, it will be every parent as well. For example: ["foo", "bar"] would return both "module.foo" and "module.foo.module.bar"

func ReferencesFromConfig Uses

func ReferencesFromConfig(c *config.RawConfig) []string

ReferencesFromConfig returns the references that a configuration has based on the interpolated variables in a configuration.

func ResolveProviderName Uses

func ResolveProviderName(name string, path []string) string

func SetDebugInfo Uses

func SetDebugInfo(path string) error

SetDebugInfo initializes the debug handler with a backing file in the provided directory. This must be called before any other terraform package operations or not at all. Once his is called, CloseDebugInfo should be called before program exit.

func TestStateFile Uses

func TestStateFile(t *testing.T, path string, state *State)

TestStateFile writes the given state to the path.

func UserAgentString Uses

func UserAgentString() string

Generate a UserAgent string

Deprecated: Use httpclient.UserAgentString if you are setting your own User-Agent header.

func Variables Uses

func Variables(
    m *module.Tree,
    override map[string]interface{}) (map[string]interface{}, error)

Variables returns the fully loaded set of variables to use with ContextOpts and NewContext, loading any additional variables from the environment or any other sources.

The given module tree doesn't need to be loaded.

func VersionString Uses

func VersionString() string

TODO: update providers to use the version package directly

func WritePlan Uses

func WritePlan(d *Plan, dst io.Writer) error

WritePlan writes a plan somewhere in a binary format.

func WriteState Uses

func WriteState(d *State, dst io.Writer) error

WriteState writes a state somewhere in a binary format.

type ApplyGraphBuilder Uses

type ApplyGraphBuilder struct {
    // Module is the root module for the graph to build.
    Module *module.Tree

    // Diff is the diff to apply.
    Diff *Diff

    // State is the current state
    State *State

    // Providers is the list of providers supported.
    Providers []string

    // Provisioners is the list of provisioners supported.
    Provisioners []string

    // Targets are resources to target. This is only required to make sure
    // unnecessary outputs aren't included in the apply graph. The plan
    // builder successfully handles targeting resources. In the future,
    // outputs should go into the diff so that this is unnecessary.
    Targets []string

    // DisableReduce, if true, will not reduce the graph. Great for testing.
    DisableReduce bool

    // Destroy, if true, represents a pure destroy operation
    Destroy bool

    // Validate will do structural validation of the graph.
    Validate bool
}

ApplyGraphBuilder implements GraphBuilder and is responsible for building a graph for applying a Terraform diff.

Because the graph is built from the diff (vs. the config or state), this helps ensure that the apply-time graph doesn't modify any resources that aren't explicitly in the diff. There are other scenarios where the diff can be deviated, so this is just one layer of protection.

func (*ApplyGraphBuilder) Build Uses

func (b *ApplyGraphBuilder) Build(path []string) (*Graph, error)

See GraphBuilder

func (*ApplyGraphBuilder) Steps Uses

func (b *ApplyGraphBuilder) Steps() []GraphTransformer

See GraphBuilder

type AttachResourceConfigTransformer Uses

type AttachResourceConfigTransformer struct {
    Module *module.Tree // Module is the root module for the config
}

AttachResourceConfigTransformer goes through the graph and attaches resource configuration structures to nodes that implement the interfaces above.

The attached configuration structures are directly from the configuration. If they're going to be modified, a copy should be made.

func (*AttachResourceConfigTransformer) Transform Uses

func (t *AttachResourceConfigTransformer) Transform(g *Graph) error

type AttachStateTransformer Uses

type AttachStateTransformer struct {
    State *State // State is the root state
}

AttachStateTransformer goes through the graph and attaches state to nodes that implement the interfaces above.

func (*AttachStateTransformer) Transform Uses

func (t *AttachStateTransformer) Transform(g *Graph) error

type BackendState Uses

type BackendState struct {
    Type   string                 `json:"type"`   // Backend type
    Config map[string]interface{} `json:"config"` // Backend raw config

    // Hash is the hash code to uniquely identify the original source
    // configuration. We use this to detect when there is a change in
    // configuration even when "type" isn't changed.
    Hash uint64 `json:"hash"`
}

BackendState stores the configuration to connect to a remote backend.

func (*BackendState) Empty Uses

func (s *BackendState) Empty() bool

Empty returns true if BackendState has no state.

func (*BackendState) Rehash Uses

func (s *BackendState) Rehash() uint64

Rehash returns a unique content hash for this backend's configuration as a uint64 value. The Hash stored in the backend state needs to match the config itself, but we need to compare the backend config after it has been combined with all options. This function must match the implementation used by config.Backend.

type BasicGraphBuilder Uses

type BasicGraphBuilder struct {
    Steps    []GraphTransformer
    Validate bool
    // Optional name to add to the graph debug log
    Name string
}

BasicGraphBuilder is a GraphBuilder that builds a graph out of a series of transforms and (optionally) validates the graph is a valid structure.

func (*BasicGraphBuilder) Build Uses

func (b *BasicGraphBuilder) Build(path []string) (*Graph, error)

type BuiltinEvalContext Uses

type BuiltinEvalContext struct {
    // StopContext is the context used to track whether we're complete
    StopContext context.Context

    // PathValue is the Path that this context is operating within.
    PathValue []string

    // Interpolater setting below affect the interpolation of variables.
    //
    // The InterpolaterVars are the exact value for ${var.foo} values.
    // The map is shared between all contexts and is a mapping of
    // PATH to KEY to VALUE. Because it is shared by all contexts as well
    // as the Interpolater itself, it is protected by InterpolaterVarLock
    // which must be locked during any access to the map.
    Interpolater        *Interpolater
    InterpolaterVars    map[string]map[string]interface{}
    InterpolaterVarLock *sync.Mutex

    Components          contextComponentFactory
    Hooks               []Hook
    InputValue          UIInput
    ProviderCache       map[string]ResourceProvider
    ProviderInputConfig map[string]map[string]interface{}
    ProviderLock        *sync.Mutex
    ProvisionerCache    map[string]ResourceProvisioner
    ProvisionerLock     *sync.Mutex
    DiffValue           *Diff
    DiffLock            *sync.RWMutex
    StateValue          *State
    StateLock           *sync.RWMutex
    // contains filtered or unexported fields
}

BuiltinEvalContext is an EvalContext implementation that is used by Terraform by default.

func (*BuiltinEvalContext) CloseProvider Uses

func (ctx *BuiltinEvalContext) CloseProvider(n string) error

func (*BuiltinEvalContext) CloseProvisioner Uses

func (ctx *BuiltinEvalContext) CloseProvisioner(n string) error

func (*BuiltinEvalContext) ConfigureProvider Uses

func (ctx *BuiltinEvalContext) ConfigureProvider(
    n string, cfg *ResourceConfig) error

func (*BuiltinEvalContext) Diff Uses

func (ctx *BuiltinEvalContext) Diff() (*Diff, *sync.RWMutex)

func (*BuiltinEvalContext) Hook Uses

func (ctx *BuiltinEvalContext) Hook(fn func(Hook) (HookAction, error)) error

func (*BuiltinEvalContext) InitProvider Uses

func (ctx *BuiltinEvalContext) InitProvider(typeName, name string) (ResourceProvider, error)

func (*BuiltinEvalContext) InitProvisioner Uses

func (ctx *BuiltinEvalContext) InitProvisioner(
    n string) (ResourceProvisioner, error)

func (*BuiltinEvalContext) Input Uses

func (ctx *BuiltinEvalContext) Input() UIInput

func (*BuiltinEvalContext) Interpolate Uses

func (ctx *BuiltinEvalContext) Interpolate(
    cfg *config.RawConfig, r *Resource) (*ResourceConfig, error)

func (*BuiltinEvalContext) InterpolateProvider Uses

func (ctx *BuiltinEvalContext) InterpolateProvider(
    pc *config.ProviderConfig, r *Resource) (*ResourceConfig, error)

func (*BuiltinEvalContext) Path Uses

func (ctx *BuiltinEvalContext) Path() []string

func (*BuiltinEvalContext) Provider Uses

func (ctx *BuiltinEvalContext) Provider(n string) ResourceProvider

func (*BuiltinEvalContext) ProviderInput Uses

func (ctx *BuiltinEvalContext) ProviderInput(n string) map[string]interface{}

func (*BuiltinEvalContext) Provisioner Uses

func (ctx *BuiltinEvalContext) Provisioner(n string) ResourceProvisioner

func (*BuiltinEvalContext) SetProviderInput Uses

func (ctx *BuiltinEvalContext) SetProviderInput(n string, c map[string]interface{})

func (*BuiltinEvalContext) SetVariables Uses

func (ctx *BuiltinEvalContext) SetVariables(n string, vs map[string]interface{})

func (*BuiltinEvalContext) State Uses

func (ctx *BuiltinEvalContext) State() (*State, *sync.RWMutex)

func (*BuiltinEvalContext) Stopped Uses

func (ctx *BuiltinEvalContext) Stopped() <-chan struct{}

type CBDEdgeTransformer Uses

type CBDEdgeTransformer struct {
    // Module and State are only needed to look up dependencies in
    // any way possible. Either can be nil if not availabile.
    Module *module.Tree
    State  *State
}

CBDEdgeTransformer modifies the edges of CBD nodes that went through the DestroyEdgeTransformer to have the right dependencies. There are two real tasks here:

1. With CBD, the destroy edge is inverted: the destroy depends on
   the creation.

2. A_d must depend on resources that depend on A. This is to enable
   the destroy to only happen once nodes that depend on A successfully
   update to A. Example: adding a web server updates the load balancer
   before deleting the old web server.

func (*CBDEdgeTransformer) Transform Uses

func (t *CBDEdgeTransformer) Transform(g *Graph) error

type CallbackUIOutput Uses

type CallbackUIOutput struct {
    OutputFn func(string)
}

func (*CallbackUIOutput) Output Uses

func (o *CallbackUIOutput) Output(v string)

type CloseProviderTransformer Uses

type CloseProviderTransformer struct{}

CloseProviderTransformer is a GraphTransformer that adds nodes to the graph that will close open provider connections that aren't needed anymore. A provider connection is not needed anymore once all depended resources in the graph are evaluated.

func (*CloseProviderTransformer) Transform Uses

func (t *CloseProviderTransformer) Transform(g *Graph) error

type CloseProvisionerTransformer Uses

type CloseProvisionerTransformer struct{}

CloseProvisionerTransformer is a GraphTransformer that adds nodes to the graph that will close open provisioner connections that aren't needed anymore. A provisioner connection is not needed anymore once all depended resources in the graph are evaluated.

func (*CloseProvisionerTransformer) Transform Uses

func (t *CloseProvisionerTransformer) Transform(g *Graph) error

type ConcreteProviderNodeFunc Uses

type ConcreteProviderNodeFunc func(*NodeAbstractProvider) dag.Vertex

ConcreteProviderNodeFunc is a callback type used to convert an abstract provider to a concrete one of some type.

type ConcreteResourceNodeFunc Uses

type ConcreteResourceNodeFunc func(*NodeAbstractResource) dag.Vertex

ConcreteResourceNodeFunc is a callback type used to convert an abstract resource to a concrete one of some type.

type ConfigTransformer Uses

type ConfigTransformer struct {
    Concrete ConcreteResourceNodeFunc

    // Module is the module to add resources from.
    Module *module.Tree

    // Unique will only add resources that aren't already present in the graph.
    Unique bool

    // Mode will only add resources that match the given mode
    ModeFilter bool
    Mode       config.ResourceMode
    // contains filtered or unexported fields
}

ConfigTransformer is a GraphTransformer that adds all the resources from the configuration to the graph.

The module used to configure this transformer must be the root module.

Only resources are added to the graph. Variables, outputs, and providers must be added via other transforms.

Unlike ConfigTransformerOld, this transformer creates a graph with all resources including module resources, rather than creating module nodes that are then "flattened".

func (*ConfigTransformer) Transform Uses

func (t *ConfigTransformer) Transform(g *Graph) error

type Context Uses

type Context struct {
    // contains filtered or unexported fields
}

Context represents all the context that Terraform needs in order to perform operations on infrastructure. This structure is built using NewContext. See the documentation for that.

Extra functions on Context can be found in context_*.go files.

func NewContext Uses

func NewContext(opts *ContextOpts) (*Context, error)

NewContext creates a new Context structure.

Once a Context is creator, the pointer values within ContextOpts should not be mutated in any way, since the pointers are copied, not the values themselves.

func (*Context) Apply Uses

func (c *Context) Apply() (*State, error)

Apply applies the changes represented by this context and returns the resulting state.

Even in the case an error is returned, the state may be returned and will potentially be partially updated. In addition to returning the resulting state, this context is updated with the latest state.

If the state is required after an error, the caller should call Context.State, rather than rely on the return value.

TODO: Apply and Refresh should either always return a state, or rely on the

State() method. Currently the helper/resource testing framework relies
on the absence of a returned state to determine if Destroy can be
called, so that will need to be refactored before this can be changed.

func (*Context) Graph Uses

func (c *Context) Graph(typ GraphType, opts *ContextGraphOpts) (*Graph, error)

Graph returns the graph used for the given operation type.

The most extensive or complex graph type is GraphTypePlan.

func (*Context) Import Uses

func (c *Context) Import(opts *ImportOpts) (*State, error)

Import takes already-created external resources and brings them under Terraform management. Import requires the exact type, name, and ID of the resources to import.

This operation is idempotent. If the requested resource is already imported, no changes are made to the state.

Further, this operation also gracefully handles partial state. If during an import there is a failure, all previously imported resources remain imported.

func (*Context) Input Uses

func (c *Context) Input(mode InputMode) error

Input asks for input to fill variables and provider configurations. This modifies the configuration in-place, so asking for Input twice may result in different UI output showing different current values.

func (*Context) Interpolater Uses

func (c *Context) Interpolater() *Interpolater

Interpolater returns an Interpolater built on a copy of the state that can be used to test interpolation values.

func (*Context) Module Uses

func (c *Context) Module() *module.Tree

Module returns the module tree associated with this context.

func (*Context) Plan Uses

func (c *Context) Plan() (*Plan, error)

Plan generates an execution plan for the given context.

The execution plan encapsulates the context and can be stored in order to reinstantiate a context later for Apply.

Plan also updates the diff of this context to be the diff generated by the plan, so Apply can be called after.

func (*Context) Refresh Uses

func (c *Context) Refresh() (*State, error)

Refresh goes through all the resources in the state and refreshes them to their latest state. This will update the state that this context works with, along with returning it.

Even in the case an error is returned, the state may be returned and will potentially be partially updated.

func (*Context) SetVariable Uses

func (c *Context) SetVariable(k string, v interface{})

SetVariable sets a variable after a context has already been built.

func (*Context) ShadowError Uses

func (c *Context) ShadowError() error

ShadowError returns any errors caught during a shadow operation.

A shadow operation is an operation run in parallel to a real operation that performs the same tasks using new logic on copied state. The results are compared to ensure that the new logic works the same as the old logic. The shadow never affects the real operation or return values.

The result of the shadow operation are only available through this function call after a real operation is complete.

For API consumers of Context, you can safely ignore this function completely if you have no interest in helping report experimental feature errors to Terraform maintainers. Otherwise, please call this function after every operation and report this to the user.

IMPORTANT: Shadow errors are _never_ critical: they _never_ affect the real state or result of a real operation. They are purely informational to assist in future Terraform versions being more stable. Please message this effectively to the end user.

This must be called only when no other operation is running (refresh, plan, etc.). The result can be used in parallel to any other operation running.

func (*Context) State Uses

func (c *Context) State() *State

State returns a copy of the current state associated with this context.

This cannot safely be called in parallel with any other Context function.

func (*Context) Stop Uses

func (c *Context) Stop()

Stop stops the running task.

Stop will block until the task completes.

func (*Context) Validate Uses

func (c *Context) Validate() tfdiags.Diagnostics

Validate validates the configuration and returns any warnings or errors.

func (*Context) Variables Uses

func (c *Context) Variables() map[string]interface{}

Variables will return the mapping of variables that were defined for this Context. If Input was called, this mapping may be different than what was given.

type ContextGraphOpts Uses

type ContextGraphOpts struct {
    // If true, validates the graph structure (checks for cycles).
    Validate bool

    // Legacy graphs only: won't prune the graph
    Verbose bool
}

type ContextGraphWalker Uses

type ContextGraphWalker struct {
    NullGraphWalker

    // Configurable values
    Context     *Context
    Operation   walkOperation
    StopContext context.Context

    // Outputs, do not set these. Do not read these while the graph
    // is being walked.
    ValidationWarnings []string
    ValidationErrors   []error
    // contains filtered or unexported fields
}

ContextGraphWalker is the GraphWalker implementation used with the Context struct to walk and evaluate the graph.

func (*ContextGraphWalker) EnterEvalTree Uses

func (w *ContextGraphWalker) EnterEvalTree(v dag.Vertex, n EvalNode) EvalNode

func (*ContextGraphWalker) EnterPath Uses

func (w *ContextGraphWalker) EnterPath(path []string) EvalContext

func (*ContextGraphWalker) ExitEvalTree Uses

func (w *ContextGraphWalker) ExitEvalTree(
    v dag.Vertex, output interface{}, err error) error

type ContextMeta Uses

type ContextMeta struct {
    Env string // Env is the state environment
}

ContextMeta is metadata about the running context. This is information that this package or structure cannot determine on its own but exposes into Terraform in various ways. This must be provided by the Context initializer.

type ContextOpts Uses

type ContextOpts struct {
    Meta               *ContextMeta
    Destroy            bool
    Diff               *Diff
    Hooks              []Hook
    Module             *module.Tree
    Parallelism        int
    State              *State
    StateFutureAllowed bool
    ProviderResolver   ResourceProviderResolver
    Provisioners       map[string]ResourceProvisionerFactory
    Shadow             bool
    Targets            []string
    Variables          map[string]interface{}

    // If non-nil, will apply as additional constraints on the provider
    // plugins that will be requested from the provider resolver.
    ProviderSHA256s    map[string][]byte
    SkipProviderVerify bool

    UIInput UIInput
}

ContextOpts are the user-configurable options to create a context with NewContext.

type CountBoundaryTransformer Uses

type CountBoundaryTransformer struct{}

CountBoundaryTransformer adds a node that depends on everything else so that it runs last in order to clean up the state for nodes that are on the "count boundary": "foo.0" when only one exists becomes "foo"

func (*CountBoundaryTransformer) Transform Uses

func (t *CountBoundaryTransformer) Transform(g *Graph) error

type DataSource Uses

type DataSource struct {
    Name string

    // SchemaAvailable is set if the provider supports the ProviderSchema,
    // ResourceTypeSchema and DataSourceSchema methods. Although it is
    // included on each resource type, it's actually a provider-wide setting
    // that's smuggled here only because that avoids a breaking change to
    // the plugin protocol.
    SchemaAvailable bool
}

DataSource is a data source that a resource provider implements.

type DebugHook Uses

type DebugHook struct{}

DebugHook implements all methods of the terraform.Hook interface, and writes the arguments to a file in the archive. When a suitable format for the argument isn't available, the argument is encoded using json.Marshal. If the debug handler is nil, all DebugHook methods are noop, so no time is spent in marshaling the data structures.

func (*DebugHook) PostApply Uses

func (*DebugHook) PostApply(ii *InstanceInfo, is *InstanceState, err error) (HookAction, error)

func (*DebugHook) PostDiff Uses

func (*DebugHook) PostDiff(ii *InstanceInfo, id *InstanceDiff) (HookAction, error)

func (*DebugHook) PostImportState Uses

func (*DebugHook) PostImportState(ii *InstanceInfo, iss []*InstanceState) (HookAction, error)

func (*DebugHook) PostProvision Uses

func (*DebugHook) PostProvision(ii *InstanceInfo, s string, err error) (HookAction, error)

func (*DebugHook) PostProvisionResource Uses

func (*DebugHook) PostProvisionResource(ii *InstanceInfo, is *InstanceState) (HookAction, error)

func (*DebugHook) PostRefresh Uses

func (*DebugHook) PostRefresh(ii *InstanceInfo, is *InstanceState) (HookAction, error)

func (*DebugHook) PostStateUpdate Uses

func (*DebugHook) PostStateUpdate(*State) (HookAction, error)

skip logging this for now, since it could be huge

func (*DebugHook) PreApply Uses

func (*DebugHook) PreApply(ii *InstanceInfo, is *InstanceState, id *InstanceDiff) (HookAction, error)

func (*DebugHook) PreDiff Uses

func (*DebugHook) PreDiff(ii *InstanceInfo, is *InstanceState) (HookAction, error)

func (*DebugHook) PreImportState Uses

func (*DebugHook) PreImportState(ii *InstanceInfo, s string) (HookAction, error)

func (*DebugHook) PreProvision Uses

func (*DebugHook) PreProvision(ii *InstanceInfo, s string) (HookAction, error)

func (*DebugHook) PreProvisionResource Uses

func (*DebugHook) PreProvisionResource(ii *InstanceInfo, is *InstanceState) (HookAction, error)

func (*DebugHook) PreRefresh Uses

func (*DebugHook) PreRefresh(ii *InstanceInfo, is *InstanceState) (HookAction, error)

func (*DebugHook) ProvisionOutput Uses

func (*DebugHook) ProvisionOutput(ii *InstanceInfo, s1 string, s2 string)

type DeposedTransformer Uses

type DeposedTransformer struct {
    // State is the global state. We'll automatically find the correct
    // ModuleState based on the Graph.Path that is being transformed.
    State *State

    // View, if non-empty, is the ModuleState.View used around the state
    // to find deposed resources.
    View string

    // The provider used by the resourced which were deposed
    ResolvedProvider string
}

DeposedTransformer is a GraphTransformer that adds deposed resources to the graph.

func (*DeposedTransformer) Transform Uses

func (t *DeposedTransformer) Transform(g *Graph) error

type DestroyEdge Uses

type DestroyEdge struct {
    S, T dag.Vertex
}

DestroyEdge is an edge that represents a standard "destroy" relationship: Target depends on Source because Source is destroying.

func (*DestroyEdge) Hashcode Uses

func (e *DestroyEdge) Hashcode() interface{}

func (*DestroyEdge) Source Uses

func (e *DestroyEdge) Source() dag.Vertex

func (*DestroyEdge) Target Uses

func (e *DestroyEdge) Target() dag.Vertex

type DestroyEdgeTransformer Uses

type DestroyEdgeTransformer struct {
    // These are needed to properly build the graph of dependencies
    // to determine what a destroy node depends on. Any of these can be nil.
    Module *module.Tree
    State  *State
}

DestroyEdgeTransformer is a GraphTransformer that creates the proper references for destroy resources. Destroy resources are more complex in that they must be depend on the destruction of resources that in turn depend on the CREATION of the node being destroy.

That is complicated. Visually:

B_d -> A_d -> A -> B

Notice that A destroy depends on B destroy, while B create depends on A create. They're inverted. This must be done for example because often dependent resources will block parent resources from deleting. Concrete example: VPC with subnets, the VPC can't be deleted while there are still subnets.

func (*DestroyEdgeTransformer) Transform Uses

func (t *DestroyEdgeTransformer) Transform(g *Graph) error

type DestroyOutputTransformer Uses

type DestroyOutputTransformer struct {
}

DestroyOutputTransformer is a GraphTransformer that adds nodes to delete outputs during destroy. We need to do this to ensure that no stale outputs are ever left in the state.

func (*DestroyOutputTransformer) Transform Uses

func (t *DestroyOutputTransformer) Transform(g *Graph) error

type DestroyPlanGraphBuilder Uses

type DestroyPlanGraphBuilder struct {
    // Module is the root module for the graph to build.
    Module *module.Tree

    // State is the current state
    State *State

    // Targets are resources to target
    Targets []string

    // Validate will do structural validation of the graph.
    Validate bool
}

DestroyPlanGraphBuilder implements GraphBuilder and is responsible for planning a pure-destroy.

Planning a pure destroy operation is simple because we can ignore most ordering configuration and simply reverse the state.

func (*DestroyPlanGraphBuilder) Build Uses

func (b *DestroyPlanGraphBuilder) Build(path []string) (*Graph, error)

See GraphBuilder

func (*DestroyPlanGraphBuilder) Steps Uses

func (b *DestroyPlanGraphBuilder) Steps() []GraphTransformer

See GraphBuilder

type DestroyValueReferenceTransformer Uses

type DestroyValueReferenceTransformer struct{}

DestroyReferenceTransformer is a GraphTransformer that reverses the edges for locals and outputs that depend on other nodes which will be removed during destroy. If a destroy node is evaluated before the local or output value, it will be removed from the state, and the later interpolation will fail.

func (*DestroyValueReferenceTransformer) Transform Uses

func (t *DestroyValueReferenceTransformer) Transform(g *Graph) error

type Diff Uses

type Diff struct {
    // Modules contains all the modules that have a diff
    Modules []*ModuleDiff
}

Diff tracks the changes that are necessary to apply a configuration to an existing infrastructure.

func (*Diff) AddModule Uses

func (d *Diff) AddModule(path []string) *ModuleDiff

AddModule adds the module with the given path to the diff.

This should be the preferred method to add module diffs since it allows us to optimize lookups later as well as control sorting.

func (*Diff) DeepCopy Uses

func (d *Diff) DeepCopy() *Diff

DeepCopy performs a deep copy of all parts of the Diff, making the resulting Diff safe to use without modifying this one.

func (*Diff) Empty Uses

func (d *Diff) Empty() bool

Empty returns true if the diff has no changes.

func (*Diff) Equal Uses

func (d *Diff) Equal(d2 *Diff) bool

Equal compares two diffs for exact equality.

This is different from the Same comparison that is supported which checks for operation equality taking into account computed values. Equal instead checks for exact equality.

func (*Diff) ModuleByPath Uses

func (d *Diff) ModuleByPath(path []string) *ModuleDiff

ModuleByPath is used to lookup the module diff for the given path. This should be the preferred lookup mechanism as it allows for future lookup optimizations.

func (*Diff) Prune Uses

func (d *Diff) Prune()

Prune cleans out unused structures in the diff without affecting the behavior of the diff at all.

This is not safe to call concurrently. This is safe to call on a nil Diff.

func (*Diff) RootModule Uses

func (d *Diff) RootModule() *ModuleDiff

RootModule returns the ModuleState for the root module

func (*Diff) String Uses

func (d *Diff) String() string

type DiffAttrType Uses

type DiffAttrType byte

DiffAttrType is an enum type that says whether a resource attribute diff is an input attribute (comes from the configuration) or an output attribute (comes as a result of applying the configuration). An example input would be "ami" for AWS and an example output would be "private_ip".

const (
    DiffAttrUnknown DiffAttrType = iota
    DiffAttrInput
    DiffAttrOutput
)

type DiffChangeType Uses

type DiffChangeType byte

DiffChangeType is an enum with the kind of changes a diff has planned.

const (
    DiffInvalid DiffChangeType = iota
    DiffNone
    DiffCreate
    DiffUpdate
    DiffDestroy
    DiffDestroyCreate

    // DiffRefresh is only used in the UI for displaying diffs.
    // Managed resource reads never appear in plan, and when data source
    // reads appear they are represented as DiffCreate in core before
    // transforming to DiffRefresh in the UI layer.
    DiffRefresh // TODO: Actually use DiffRefresh in core too, for less confusion
)

type DiffTransformer Uses

type DiffTransformer struct {
    Concrete ConcreteResourceNodeFunc

    Diff   *Diff
    Module *module.Tree
    State  *State
}

DiffTransformer is a GraphTransformer that adds the elements of the diff to the graph.

This transform is used for example by the ApplyGraphBuilder to ensure that only resources that are being modified are represented in the graph.

Module and State is still required for the DiffTransformer for annotations since the Diff doesn't contain all the information required to build the complete graph (such as create-before-destroy information). The graph is built based on the diff first, though, ensuring that only resources that are being modified are present in the graph.

func (*DiffTransformer) Transform Uses

func (t *DiffTransformer) Transform(g *Graph) error

type EphemeralState Uses

type EphemeralState struct {
    // ConnInfo is used for the providers to export information which is
    // used to connect to the resource for provisioning. For example,
    // this could contain SSH or WinRM credentials.
    ConnInfo map[string]string `json:"-"`

    // Type is used to specify the resource type for this instance. This is only
    // required for import operations (as documented). If the documentation
    // doesn't state that you need to set this, then don't worry about
    // setting it.
    Type string `json:"-"`
}

EphemeralState is used for transient state that is only kept in-memory

func (*EphemeralState) DeepCopy Uses

func (e *EphemeralState) DeepCopy() *EphemeralState

type EvalApply Uses

type EvalApply struct {
    Info      *InstanceInfo
    State     **InstanceState
    Diff      **InstanceDiff
    Provider  *ResourceProvider
    Output    **InstanceState
    CreateNew *bool
    Error     *error
}

EvalApply is an EvalNode implementation that writes the diff to the full diff.

func (*EvalApply) Eval Uses

func (n *EvalApply) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalApplyPost Uses

type EvalApplyPost struct {
    Info  *InstanceInfo
    State **InstanceState
    Error *error
}

EvalApplyPost is an EvalNode implementation that does the post-Apply work

func (*EvalApplyPost) Eval Uses

func (n *EvalApplyPost) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalApplyPre Uses

type EvalApplyPre struct {
    Info  *InstanceInfo
    State **InstanceState
    Diff  **InstanceDiff
}

EvalApplyPre is an EvalNode implementation that does the pre-Apply work

func (*EvalApplyPre) Eval Uses

func (n *EvalApplyPre) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalApplyProvisioners Uses

type EvalApplyProvisioners struct {
    Info           *InstanceInfo
    State          **InstanceState
    Resource       *config.Resource
    InterpResource *Resource
    CreateNew      *bool
    Error          *error

    // When is the type of provisioner to run at this point
    When config.ProvisionerWhen
}

EvalApplyProvisioners is an EvalNode implementation that executes the provisioners for a resource.

TODO(mitchellh): This should probably be split up into a more fine-grained ApplyProvisioner (single) that is looped over.

func (*EvalApplyProvisioners) Eval Uses

func (n *EvalApplyProvisioners) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalBuildProviderConfig Uses

type EvalBuildProviderConfig struct {
    Provider string
    Config   **ResourceConfig
    Output   **ResourceConfig
}

EvalBuildProviderConfig outputs a *ResourceConfig that is properly merged with parents and inputs on top of what is configured in the file.

func (*EvalBuildProviderConfig) Eval Uses

func (n *EvalBuildProviderConfig) Eval(ctx EvalContext) (interface{}, error)

type EvalCheckPreventDestroy Uses

type EvalCheckPreventDestroy struct {
    Resource   *config.Resource
    ResourceId string
    Diff       **InstanceDiff
}

EvalPreventDestroy is an EvalNode implementation that returns an error if a resource has PreventDestroy configured and the diff would destroy the resource.

func (*EvalCheckPreventDestroy) Eval Uses

func (n *EvalCheckPreventDestroy) Eval(ctx EvalContext) (interface{}, error)

type EvalCloseProvider Uses

type EvalCloseProvider struct {
    Name string
}

EvalCloseProvider is an EvalNode implementation that closes provider connections that aren't needed anymore.

func (*EvalCloseProvider) Eval Uses

func (n *EvalCloseProvider) Eval(ctx EvalContext) (interface{}, error)

type EvalCloseProvisioner Uses

type EvalCloseProvisioner struct {
    Name string
}

EvalCloseProvisioner is an EvalNode implementation that closes provisioner connections that aren't needed anymore.

func (*EvalCloseProvisioner) Eval Uses

func (n *EvalCloseProvisioner) Eval(ctx EvalContext) (interface{}, error)

type EvalCoerceMapVariable Uses

type EvalCoerceMapVariable struct {
    Variables  map[string]interface{}
    ModulePath []string
    ModuleTree *module.Tree
}

EvalCoerceMapVariable is an EvalNode implementation that recognizes a specific ambiguous HCL parsing situation and resolves it. In HCL parsing, a bare map literal is indistinguishable from a list of maps w/ one element.

We take all the same inputs as EvalTypeCheckVariable above, since we need both the target type and the proposed value in order to properly coerce.

func (*EvalCoerceMapVariable) Eval Uses

func (n *EvalCoerceMapVariable) Eval(ctx EvalContext) (interface{}, error)

Eval implements the EvalNode interface. See EvalCoerceMapVariable for details.

type EvalCompareDiff Uses

type EvalCompareDiff struct {
    Info     *InstanceInfo
    One, Two **InstanceDiff
}

EvalCompareDiff is an EvalNode implementation that compares two diffs and errors if the diffs are not equal.

func (*EvalCompareDiff) Eval Uses

func (n *EvalCompareDiff) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalConfigProvider Uses

type EvalConfigProvider struct {
    Provider string
    Config   **ResourceConfig
}

EvalConfigProvider is an EvalNode implementation that configures a provider that is already initialized and retrieved.

func (*EvalConfigProvider) Eval Uses

func (n *EvalConfigProvider) Eval(ctx EvalContext) (interface{}, error)

type EvalContext Uses

type EvalContext interface {
    // Stopped returns a channel that is closed when evaluation is stopped
    // via Terraform.Context.Stop()
    Stopped() <-chan struct{}

    // Path is the current module path.
    Path() []string

    // Hook is used to call hook methods. The callback is called for each
    // hook and should return the hook action to take and the error.
    Hook(func(Hook) (HookAction, error)) error

    // Input is the UIInput object for interacting with the UI.
    Input() UIInput

    // InitProvider initializes the provider with the given type and name, and
    // returns the implementation of the resource provider or an error.
    //
    // It is an error to initialize the same provider more than once.
    InitProvider(typ string, name string) (ResourceProvider, error)

    // Provider gets the provider instance with the given name (already
    // initialized) or returns nil if the provider isn't initialized.
    Provider(string) ResourceProvider

    // CloseProvider closes provider connections that aren't needed anymore.
    CloseProvider(string) error

    // ConfigureProvider configures the provider with the given
    // configuration. This is a separate context call because this call
    // is used to store the provider configuration for inheritance lookups
    // with ParentProviderConfig().
    ConfigureProvider(string, *ResourceConfig) error

    // ProviderInput and SetProviderInput are used to configure providers
    // from user input.
    ProviderInput(string) map[string]interface{}
    SetProviderInput(string, map[string]interface{})

    // InitProvisioner initializes the provisioner with the given name and
    // returns the implementation of the resource provisioner or an error.
    //
    // It is an error to initialize the same provisioner more than once.
    InitProvisioner(string) (ResourceProvisioner, error)

    // Provisioner gets the provisioner instance with the given name (already
    // initialized) or returns nil if the provisioner isn't initialized.
    Provisioner(string) ResourceProvisioner

    // CloseProvisioner closes provisioner connections that aren't needed
    // anymore.
    CloseProvisioner(string) error

    // Interpolate takes the given raw configuration and completes
    // the interpolations, returning the processed ResourceConfig.
    //
    // The resource argument is optional. If given, it is the resource
    // that is currently being acted upon.
    Interpolate(*config.RawConfig, *Resource) (*ResourceConfig, error)

    // InterpolateProvider takes a ProviderConfig and interpolates it with the
    // stored interpolation scope. Since provider configurations can be
    // inherited, the interpolation scope may be different from the current
    // context path. Interplation is otherwise executed the same as in the
    // Interpolation method.
    InterpolateProvider(*config.ProviderConfig, *Resource) (*ResourceConfig, error)

    // SetVariables sets the variables for the module within
    // this context with the name n. This function call is additive:
    // the second parameter is merged with any previous call.
    SetVariables(string, map[string]interface{})

    // Diff returns the global diff as well as the lock that should
    // be used to modify that diff.
    Diff() (*Diff, *sync.RWMutex)

    // State returns the global state as well as the lock that should
    // be used to modify that state.
    State() (*State, *sync.RWMutex)
}

EvalContext is the interface that is given to eval nodes to execute.

type EvalCountCheckComputed Uses

type EvalCountCheckComputed struct {
    Resource *config.Resource
}

EvalCountCheckComputed is an EvalNode that checks if a resource count is computed and errors if so. This can possibly happen across a module boundary and we don't yet support this.

func (*EvalCountCheckComputed) Eval Uses

func (n *EvalCountCheckComputed) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalCountFixZeroOneBoundary Uses

type EvalCountFixZeroOneBoundary struct {
    Resource *config.Resource
}

EvalCountFixZeroOneBoundary is an EvalNode that fixes up the state when there is a resource count with zero/one boundary, i.e. fixing a resource named "aws_instance.foo" to "aws_instance.foo.0" and vice-versa.

func (*EvalCountFixZeroOneBoundary) Eval Uses

func (n *EvalCountFixZeroOneBoundary) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalCountFixZeroOneBoundaryGlobal Uses

type EvalCountFixZeroOneBoundaryGlobal struct{}

EvalCountFixZeroOneBoundaryGlobal is an EvalNode that fixes up the state when there is a resource count with zero/one boundary, i.e. fixing a resource named "aws_instance.foo" to "aws_instance.foo.0" and vice-versa.

This works on the global state.

func (*EvalCountFixZeroOneBoundaryGlobal) Eval Uses

func (n *EvalCountFixZeroOneBoundaryGlobal) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalDeleteLocal Uses

type EvalDeleteLocal struct {
    Name string
}

EvalDeleteLocal is an EvalNode implementation that deletes a Local value from the state. Locals aren't persisted, but we don't need to evaluate them during destroy.

func (*EvalDeleteLocal) Eval Uses

func (n *EvalDeleteLocal) Eval(ctx EvalContext) (interface{}, error)

type EvalDeleteModule Uses

type EvalDeleteModule struct {
    PathValue []string
}

EvalDeleteModule is an EvalNode implementation that removes an empty module entry from the state.

func (*EvalDeleteModule) Eval Uses

func (n *EvalDeleteModule) Eval(ctx EvalContext) (interface{}, error)

type EvalDeleteOutput Uses

type EvalDeleteOutput struct {
    Name string
}

EvalDeleteOutput is an EvalNode implementation that deletes an output from the state.

func (*EvalDeleteOutput) Eval Uses

func (n *EvalDeleteOutput) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalDeposeState Uses

type EvalDeposeState struct {
    Name string
}

EvalDeposeState is an EvalNode implementation that takes the primary out of a state and makes it Deposed. This is done at the beginning of create-before-destroy calls so that the create can create while preserving the old state of the to-be-destroyed resource.

func (*EvalDeposeState) Eval Uses

func (n *EvalDeposeState) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalDiff Uses

type EvalDiff struct {
    Name        string
    Info        *InstanceInfo
    Config      **ResourceConfig
    Provider    *ResourceProvider
    Diff        **InstanceDiff
    State       **InstanceState
    OutputDiff  **InstanceDiff
    OutputState **InstanceState

    // Resource is needed to fetch the ignore_changes list so we can
    // filter user-requested ignored attributes from the diff.
    Resource *config.Resource

    // Stub is used to flag the generated InstanceDiff as a stub. This is used to
    // ensure that the node exists to perform interpolations and generate
    // computed paths off of, but not as an actual diff where resouces should be
    // counted, and not as a diff that should be acted on.
    Stub bool
}

EvalDiff is an EvalNode implementation that does a refresh for a resource.

func (*EvalDiff) Eval Uses

func (n *EvalDiff) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalDiffDestroy Uses

type EvalDiffDestroy struct {
    Info   *InstanceInfo
    State  **InstanceState
    Output **InstanceDiff
}

EvalDiffDestroy is an EvalNode implementation that returns a plain destroy diff.

func (*EvalDiffDestroy) Eval Uses

func (n *EvalDiffDestroy) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalDiffDestroyModule Uses

type EvalDiffDestroyModule struct {
    Path []string
}

EvalDiffDestroyModule is an EvalNode implementation that writes the diff to the full diff.

func (*EvalDiffDestroyModule) Eval Uses

func (n *EvalDiffDestroyModule) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalEarlyExitError Uses

type EvalEarlyExitError struct{}

EvalEarlyExitError is a special error return value that can be returned by eval nodes that does an early exit.

func (EvalEarlyExitError) Error Uses

func (EvalEarlyExitError) Error() string

type EvalFilterDiff Uses

type EvalFilterDiff struct {
    // Input and output
    Diff   **InstanceDiff
    Output **InstanceDiff

    // Destroy, if true, will only include a destroy diff if it is set.
    Destroy bool
}

EvalFilterDiff is an EvalNode implementation that filters the diff according to some filter.

func (*EvalFilterDiff) Eval Uses

func (n *EvalFilterDiff) Eval(ctx EvalContext) (interface{}, error)

type EvalGetProvider Uses

type EvalGetProvider struct {
    Name   string
    Output *ResourceProvider
}

EvalGetProvider is an EvalNode implementation that retrieves an already initialized provider instance for the given name.

func (*EvalGetProvider) Eval Uses

func (n *EvalGetProvider) Eval(ctx EvalContext) (interface{}, error)

type EvalGetProvisioner Uses

type EvalGetProvisioner struct {
    Name   string
    Output *ResourceProvisioner
}

EvalGetProvisioner is an EvalNode implementation that retrieves an already initialized provisioner instance for the given name.

func (*EvalGetProvisioner) Eval Uses

func (n *EvalGetProvisioner) Eval(ctx EvalContext) (interface{}, error)

type EvalIf Uses

type EvalIf struct {
    If   func(EvalContext) (bool, error)
    Then EvalNode
    Else EvalNode
}

EvalIf is an EvalNode that is a conditional.

func (*EvalIf) Eval Uses

func (n *EvalIf) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalImportState Uses

type EvalImportState struct {
    Provider *ResourceProvider
    Info     *InstanceInfo
    Id       string
    Output   *[]*InstanceState
}

EvalImportState is an EvalNode implementation that performs an ImportState operation on a provider. This will return the imported states but won't modify any actual state.

func (*EvalImportState) Eval Uses

func (n *EvalImportState) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalImportStateVerify Uses

type EvalImportStateVerify struct {
    Info  *InstanceInfo
    Id    string
    State **InstanceState
}

EvalImportStateVerify verifies the state after ImportState and after the refresh to make sure it is non-nil and valid.

func (*EvalImportStateVerify) Eval Uses

func (n *EvalImportStateVerify) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalInitProvider Uses

type EvalInitProvider struct {
    TypeName string
    Name     string
}

EvalInitProvider is an EvalNode implementation that initializes a provider and returns nothing. The provider can be retrieved again with the EvalGetProvider node.

func (*EvalInitProvider) Eval Uses

func (n *EvalInitProvider) Eval(ctx EvalContext) (interface{}, error)

type EvalInitProvisioner Uses

type EvalInitProvisioner struct {
    Name string
}

EvalInitProvisioner is an EvalNode implementation that initializes a provisioner and returns nothing. The provisioner can be retrieved again with the EvalGetProvisioner node.

func (*EvalInitProvisioner) Eval Uses

func (n *EvalInitProvisioner) Eval(ctx EvalContext) (interface{}, error)

type EvalInputProvider Uses

type EvalInputProvider struct {
    Name     string
    Provider *ResourceProvider
    Config   **ResourceConfig
}

EvalInputProvider is an EvalNode implementation that asks for input for the given provider configurations.

func (*EvalInputProvider) Eval Uses

func (n *EvalInputProvider) Eval(ctx EvalContext) (interface{}, error)

type EvalInstanceInfo Uses

type EvalInstanceInfo struct {
    Info *InstanceInfo
}

EvalInstanceInfo is an EvalNode implementation that fills in the InstanceInfo as much as it can.

func (*EvalInstanceInfo) Eval Uses

func (n *EvalInstanceInfo) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalInterpolate Uses

type EvalInterpolate struct {
    Config        *config.RawConfig
    Resource      *Resource
    Output        **ResourceConfig
    ContinueOnErr bool
}

EvalInterpolate is an EvalNode implementation that takes a raw configuration and interpolates it.

func (*EvalInterpolate) Eval Uses

func (n *EvalInterpolate) Eval(ctx EvalContext) (interface{}, error)

type EvalInterpolateProvider Uses

type EvalInterpolateProvider struct {
    Config   *config.ProviderConfig
    Resource *Resource
    Output   **ResourceConfig
}

EvalInterpolateProvider is an EvalNode implementation that takes a ProviderConfig and interpolates it. Provider configurations are the only "inherited" type of configuration we have, and the original raw config may have a different interpolation scope.

func (*EvalInterpolateProvider) Eval Uses

func (n *EvalInterpolateProvider) Eval(ctx EvalContext) (interface{}, error)

type EvalLocal Uses

type EvalLocal struct {
    Name  string
    Value *config.RawConfig
}

EvalLocal is an EvalNode implementation that evaluates the expression for a local value and writes it into a transient part of the state.

func (*EvalLocal) Eval Uses

func (n *EvalLocal) Eval(ctx EvalContext) (interface{}, error)

type EvalNode Uses

type EvalNode interface {
    // Eval evaluates this node with the given context. The second parameter
    // are the argument values. These will match in order and 1-1 with the
    // results of the Args() return value.
    Eval(EvalContext) (interface{}, error)
}

EvalNode is the interface that must be implemented by graph nodes to evaluate/execute.

func CloseProviderEvalTree Uses

func CloseProviderEvalTree(n string) EvalNode

CloseProviderEvalTree returns the evaluation tree for closing provider connections that aren't needed anymore.

func EvalFilter Uses

func EvalFilter(node EvalNode, fn EvalNodeFilterFunc) EvalNode

EvalFilter runs the filter on the given node and returns the final filtered value. This should be called rather than checking the EvalNode directly since this will properly handle EvalNodeFilterables.

func ProviderEvalTree Uses

func ProviderEvalTree(n *NodeApplyableProvider, config *config.ProviderConfig) EvalNode

ProviderEvalTree returns the evaluation tree for initializing and configuring providers.

type EvalNodeFilterFunc Uses

type EvalNodeFilterFunc func(EvalNode) EvalNode

EvalNodeFilterFunc is the callback used to replace a node with another to node. To not do the replacement, just return the input node.

func EvalNodeFilterOp Uses

func EvalNodeFilterOp(op walkOperation) EvalNodeFilterFunc

EvalNodeFilterOp returns a filter function that filters nodes that include themselves in specific operations.

type EvalNodeFilterable Uses

type EvalNodeFilterable interface {
    EvalNode
    Filter(EvalNodeFilterFunc)
}

EvalNodeFilterable is an interface that can be implemented by EvalNodes to allow filtering of sub-elements. Note that this isn't a common thing to implement and you probably don't need it.

type EvalNodeOpFilterable Uses

type EvalNodeOpFilterable interface {
    IncludeInOp(walkOperation) bool
}

EvalNodeOpFilterable is an interface that EvalNodes can implement to be filterable by the operation that is being run on Terraform.

type EvalNoop Uses

type EvalNoop struct{}

EvalNoop is an EvalNode that does nothing.

func (EvalNoop) Eval Uses

func (EvalNoop) Eval(EvalContext) (interface{}, error)

type EvalOpFilter Uses

type EvalOpFilter struct {
    // Ops is the list of operations to include this node in.
    Ops []walkOperation

    // Node is the node to execute
    Node EvalNode
}

EvalOpFilter is an EvalNode implementation that is a proxy to another node but filters based on the operation.

func (*EvalOpFilter) Eval Uses

func (n *EvalOpFilter) Eval(ctx EvalContext) (interface{}, error)

TODO: test

func (*EvalOpFilter) IncludeInOp Uses

func (n *EvalOpFilter) IncludeInOp(op walkOperation) bool

EvalNodeOpFilterable impl.

type EvalReadDataApply Uses

type EvalReadDataApply struct {
    Provider *ResourceProvider
    Output   **InstanceState
    Diff     **InstanceDiff
    Info     *InstanceInfo
}

EvalReadDataApply is an EvalNode implementation that executes a data resource's ReadDataApply method to read data from the data source.

func (*EvalReadDataApply) Eval Uses

func (n *EvalReadDataApply) Eval(ctx EvalContext) (interface{}, error)

type EvalReadDataDiff Uses

type EvalReadDataDiff struct {
    Provider    *ResourceProvider
    Output      **InstanceDiff
    OutputState **InstanceState
    Config      **ResourceConfig
    Info        *InstanceInfo

    // Set Previous when re-evaluating diff during apply, to ensure that
    // the "Destroy" flag is preserved.
    Previous **InstanceDiff
}

EvalReadDataDiff is an EvalNode implementation that executes a data resource's ReadDataDiff method to discover what attributes it exports.

func (*EvalReadDataDiff) Eval Uses

func (n *EvalReadDataDiff) Eval(ctx EvalContext) (interface{}, error)

type EvalReadDiff Uses

type EvalReadDiff struct {
    Name string
    Diff **InstanceDiff
}

EvalReadDiff is an EvalNode implementation that writes the diff to the full diff.

func (*EvalReadDiff) Eval Uses

func (n *EvalReadDiff) Eval(ctx EvalContext) (interface{}, error)

type EvalReadState Uses

type EvalReadState struct {
    Name   string
    Output **InstanceState
}

EvalReadState is an EvalNode implementation that reads the primary InstanceState for a specific resource out of the state.

func (*EvalReadState) Eval Uses

func (n *EvalReadState) Eval(ctx EvalContext) (interface{}, error)

type EvalReadStateDeposed Uses

type EvalReadStateDeposed struct {
    Name   string
    Output **InstanceState
    // Index indicates which instance in the Deposed list to target, or -1 for
    // the last item.
    Index int
}

EvalReadStateDeposed is an EvalNode implementation that reads the deposed InstanceState for a specific resource out of the state

func (*EvalReadStateDeposed) Eval Uses

func (n *EvalReadStateDeposed) Eval(ctx EvalContext) (interface{}, error)

type EvalRefresh Uses

type EvalRefresh struct {
    Provider *ResourceProvider
    State    **InstanceState
    Info     *InstanceInfo
    Output   **InstanceState
}

EvalRefresh is an EvalNode implementation that does a refresh for a resource.

func (*EvalRefresh) Eval Uses

func (n *EvalRefresh) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalRequireState Uses

type EvalRequireState struct {
    State **InstanceState
}

EvalRequireState is an EvalNode implementation that early exits if the state doesn't have an ID.

func (*EvalRequireState) Eval Uses

func (n *EvalRequireState) Eval(ctx EvalContext) (interface{}, error)

type EvalReturnError Uses

type EvalReturnError struct {
    Error *error
}

EvalReturnError is an EvalNode implementation that returns an error if it is present.

This is useful for scenarios where an error has been captured by another EvalNode (like EvalApply) for special EvalTree-based error handling, and that handling has completed, so the error should be returned normally.

func (*EvalReturnError) Eval Uses

func (n *EvalReturnError) Eval(ctx EvalContext) (interface{}, error)

type EvalSequence Uses

type EvalSequence struct {
    Nodes []EvalNode
}

EvalSequence is an EvalNode that evaluates in sequence.

func (*EvalSequence) Eval Uses

func (n *EvalSequence) Eval(ctx EvalContext) (interface{}, error)

func (*EvalSequence) Filter Uses

func (n *EvalSequence) Filter(fn EvalNodeFilterFunc)

EvalNodeFilterable impl.

type EvalSetVariables Uses

type EvalSetVariables struct {
    Module    *string
    Variables map[string]interface{}
}

EvalSetVariables is an EvalNode implementation that sets the variables explicitly for interpolation later.

func (*EvalSetVariables) Eval Uses

func (n *EvalSetVariables) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalTypeCheckVariable Uses

type EvalTypeCheckVariable struct {
    Variables  map[string]interface{}
    ModulePath []string
    ModuleTree *module.Tree
}

EvalTypeCheckVariable is an EvalNode which ensures that the variable values which are assigned as inputs to a module (including the root) match the types which are either declared for the variables explicitly or inferred from the default values.

In order to achieve this three things are required:

- a map of the proposed variable values
- the configuration tree of the module in which the variable is
  declared
- the path to the module (so we know which part of the tree to
  compare the values against).

func (*EvalTypeCheckVariable) Eval Uses

func (n *EvalTypeCheckVariable) Eval(ctx EvalContext) (interface{}, error)

type EvalUndeposeState Uses

type EvalUndeposeState struct {
    Name  string
    State **InstanceState
}

EvalUndeposeState is an EvalNode implementation that reads the InstanceState for a specific resource out of the state.

func (*EvalUndeposeState) Eval Uses

func (n *EvalUndeposeState) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalUpdateStateHook Uses

type EvalUpdateStateHook struct{}

EvalUpdateStateHook is an EvalNode implementation that calls the PostStateUpdate hook with the current state.

func (*EvalUpdateStateHook) Eval Uses

func (n *EvalUpdateStateHook) Eval(ctx EvalContext) (interface{}, error)

type EvalValidateCount Uses

type EvalValidateCount struct {
    Resource *config.Resource
}

EvalValidateCount is an EvalNode implementation that validates the count of a resource.

func (*EvalValidateCount) Eval Uses

func (n *EvalValidateCount) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalValidateError Uses

type EvalValidateError struct {
    Warnings []string
    Errors   []error
}

EvalValidateError is the error structure returned if there were validation errors.

func (*EvalValidateError) Error Uses

func (e *EvalValidateError) Error() string

type EvalValidateProvider Uses

type EvalValidateProvider struct {
    Provider *ResourceProvider
    Config   **ResourceConfig
}

EvalValidateProvider is an EvalNode implementation that validates the configuration of a resource.

func (*EvalValidateProvider) Eval Uses

func (n *EvalValidateProvider) Eval(ctx EvalContext) (interface{}, error)

type EvalValidateProvisioner Uses

type EvalValidateProvisioner struct {
    Provisioner *ResourceProvisioner
    Config      **ResourceConfig
    ConnConfig  **ResourceConfig
}

EvalValidateProvisioner is an EvalNode implementation that validates the configuration of a resource.

func (*EvalValidateProvisioner) Eval Uses

func (n *EvalValidateProvisioner) Eval(ctx EvalContext) (interface{}, error)

type EvalValidateResource Uses

type EvalValidateResource struct {
    Provider     *ResourceProvider
    Config       **ResourceConfig
    ResourceName string
    ResourceType string
    ResourceMode config.ResourceMode

    // IgnoreWarnings means that warnings will not be passed through. This allows
    // "just-in-time" passes of validation to continue execution through warnings.
    IgnoreWarnings bool
}

EvalValidateResource is an EvalNode implementation that validates the configuration of a resource.

func (*EvalValidateResource) Eval Uses

func (n *EvalValidateResource) Eval(ctx EvalContext) (interface{}, error)

type EvalValidateResourceSelfRef Uses

type EvalValidateResourceSelfRef struct {
    Addr   **ResourceAddress
    Config **config.RawConfig
}

EvalValidateResourceSelfRef is an EvalNode implementation that validates that a configuration doesn't contain a reference to the resource itself.

This must be done prior to interpolating configuration in order to avoid any infinite loop scenarios.

func (*EvalValidateResourceSelfRef) Eval Uses

func (n *EvalValidateResourceSelfRef) Eval(ctx EvalContext) (interface{}, error)

type EvalVariableBlock Uses

type EvalVariableBlock struct {
    Config         **ResourceConfig
    VariableValues map[string]interface{}
}

EvalVariableBlock is an EvalNode implementation that evaluates the given configuration, and uses the final values as a way to set the mapping.

func (*EvalVariableBlock) Eval Uses

func (n *EvalVariableBlock) Eval(ctx EvalContext) (interface{}, error)

type EvalWriteDiff Uses

type EvalWriteDiff struct {
    Name string
    Diff **InstanceDiff
}

EvalWriteDiff is an EvalNode implementation that writes the diff to the full diff.

func (*EvalWriteDiff) Eval Uses

func (n *EvalWriteDiff) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalWriteOutput Uses

type EvalWriteOutput struct {
    Name      string
    Sensitive bool
    Value     *config.RawConfig
    // ContinueOnErr allows interpolation to fail during Input
    ContinueOnErr bool
}

EvalWriteOutput is an EvalNode implementation that writes the output for the given name to the current state.

func (*EvalWriteOutput) Eval Uses

func (n *EvalWriteOutput) Eval(ctx EvalContext) (interface{}, error)

TODO: test

type EvalWriteState Uses

type EvalWriteState struct {
    Name         string
    ResourceType string
    Provider     string
    Dependencies []string
    State        **InstanceState
}

EvalWriteState is an EvalNode implementation that writes the primary InstanceState for a specific resource into the state.

func (*EvalWriteState) Eval Uses

func (n *EvalWriteState) Eval(ctx EvalContext) (interface{}, error)

type EvalWriteStateDeposed Uses

type EvalWriteStateDeposed struct {
    Name         string
    ResourceType string
    Provider     string
    Dependencies []string
    State        **InstanceState
    // Index indicates which instance in the Deposed list to target, or -1 to append.
    Index int
}

EvalWriteStateDeposed is an EvalNode implementation that writes an InstanceState out to the Deposed list of a resource in the state.

func (*EvalWriteStateDeposed) Eval Uses

func (n *EvalWriteStateDeposed) Eval(ctx EvalContext) (interface{}, error)

type ExpandTransform Uses

type ExpandTransform struct {
    Builder GraphBuilder
}

ExpandTransform is a transformer that does a subgraph expansion at graph transform time (vs. at eval time). The benefit of earlier subgraph expansion is that errors with the graph build can be detected at an earlier stage.

func (*ExpandTransform) Transform Uses

func (t *ExpandTransform) Transform(v dag.Vertex) (dag.Vertex, error)

type FlatConfigTransformer Uses

type FlatConfigTransformer struct {
    Concrete ConcreteResourceNodeFunc // What to turn resources into

    Module *module.Tree
}

FlatConfigTransformer is a GraphTransformer that adds the configuration to the graph. The module used to configure this transformer must be the root module.

This transform adds the nodes but doesn't connect any of the references. The ReferenceTransformer should be used for that.

NOTE: In relation to ConfigTransformer: this is a newer generation config transformer. It puts the _entire_ config into the graph (there is no "flattening" step as before).

func (*FlatConfigTransformer) Transform Uses

func (t *FlatConfigTransformer) Transform(g *Graph) error

type Graph Uses

type Graph struct {
    // Graph is the actual DAG. This is embedded so you can call the DAG
    // methods directly.
    dag.AcyclicGraph

    // Path is the path in the module tree that this Graph represents.
    // The root is represented by a single element list containing
    // RootModuleName
    Path []string
    // contains filtered or unexported fields
}

Graph represents the graph that Terraform uses to represent resources and their dependencies.

func (*Graph) DirectedGraph Uses

func (g *Graph) DirectedGraph() dag.Grapher

func (*Graph) Walk Uses

func (g *Graph) Walk(walker GraphWalker) error

Walk walks the graph with the given walker for callbacks. The graph will be walked with full parallelism, so the walker should expect to be called in concurrently.

type GraphBuilder Uses

type GraphBuilder interface {
    // Build builds the graph for the given module path. It is up to
    // the interface implementation whether this build should expand
    // the graph or not.
    Build(path []string) (*Graph, error)
}

GraphBuilder is an interface that can be implemented and used with Terraform to build the graph that Terraform walks.

func InputGraphBuilder Uses

func InputGraphBuilder(p *PlanGraphBuilder) GraphBuilder

InputGraphBuilder creates the graph for the input operation.

Unlike other graph builders, this is a function since it currently modifies and is based on the PlanGraphBuilder. The PlanGraphBuilder passed in will be modified and should not be used for any other operations.

func ValidateGraphBuilder Uses

func ValidateGraphBuilder(p *PlanGraphBuilder) GraphBuilder

ValidateGraphBuilder creates the graph for the validate operation.

ValidateGraphBuilder is based on the PlanGraphBuilder. We do this so that we only have to validate what we'd normally plan anyways. The PlanGraphBuilder given will be modified so it shouldn't be used for anything else after calling this function.

type GraphNodeAttachProvider Uses

type GraphNodeAttachProvider interface {
    // Must be implemented to determine the path for the configuration
    GraphNodeSubPath

    // ProviderName with no module prefix. Example: "aws".
    ProviderName() string

    // Sets the configuration
    AttachProvider(*config.ProviderConfig)
}

GraphNodeAttachProvider is an interface that must be implemented by nodes that want provider configurations attached.

type GraphNodeAttachResourceConfig Uses

type GraphNodeAttachResourceConfig interface {
    // ResourceAddr is the address to the resource
    ResourceAddr() *ResourceAddress

    // Sets the configuration
    AttachResourceConfig(*config.Resource)
}

GraphNodeAttachResourceConfig is an interface that must be implemented by nodes that want resource configurations attached.

type GraphNodeAttachResourceState Uses

type GraphNodeAttachResourceState interface {
    // The address to the resource for the state
    ResourceAddr() *ResourceAddress

    // Sets the state
    AttachResourceState(*ResourceState)
}

GraphNodeAttachResourceState is an interface that can be implemented to request that a ResourceState is attached to the node.

type GraphNodeCloseProvider Uses

type GraphNodeCloseProvider interface {
    CloseProviderName() string
}

GraphNodeCloseProvider is an interface that nodes that can be a close provider must implement. The CloseProviderName returned is the name of the provider they satisfy.

type GraphNodeCloseProvisioner Uses

type GraphNodeCloseProvisioner interface {
    CloseProvisionerName() string
}

GraphNodeCloseProvisioner is an interface that nodes that can be a close provisioner must implement. The CloseProvisionerName returned is the name of the provisioner they satisfy.

type GraphNodeCreator Uses

type GraphNodeCreator interface {
    // ResourceAddr is the address of the resource being created or updated
    CreateAddr() *ResourceAddress
}

GraphNodeCreator must be implemented by nodes that create OR update resources.

type GraphNodeDestroyer Uses

type GraphNodeDestroyer interface {
    dag.Vertex

    // ResourceAddr is the address of the resource that is being
    // destroyed by this node. If this returns nil, then this node
    // is not destroying anything.
    DestroyAddr() *ResourceAddress
}

GraphNodeDestroyer must be implemented by nodes that destroy resources.

type GraphNodeDestroyerCBD Uses

type GraphNodeDestroyerCBD interface {
    GraphNodeDestroyer

    // CreateBeforeDestroy returns true if this node represents a node
    // that is doing a CBD.
    CreateBeforeDestroy() bool

    // ModifyCreateBeforeDestroy is called when the CBD state of a node
    // is changed dynamically. This can return an error if this isn't
    // allowed.
    ModifyCreateBeforeDestroy(bool) error
}

GraphNodeDestroyerCBD must be implemented by nodes that might be create-before-destroy destroyers.

type GraphNodeDynamicExpandable Uses

type GraphNodeDynamicExpandable interface {
    DynamicExpand(EvalContext) (*Graph, error)
}

GraphNodeDynamicExpandable is an interface that nodes can implement to signal that they can be expanded at eval-time (hence dynamic). These nodes are given the eval context and are expected to return a new subgraph.

type GraphNodeEvalable Uses

type GraphNodeEvalable interface {
    EvalTree() EvalNode
}

GraphNodeEvalable is the interface that graph nodes must implement to enable valuation.

type GraphNodeExpandable Uses

type GraphNodeExpandable interface {
    Expand(GraphBuilder) (GraphNodeSubgraph, error)
}

GraphNodeExapndable is an interface that nodes can implement to signal that they can be expanded. Expanded nodes turn into GraphNodeSubgraph nodes within the graph.

type GraphNodeProvider Uses

type GraphNodeProvider interface {
    ProviderName() string
    Name() string
}

GraphNodeProvider is an interface that nodes that can be a provider must implement. ProviderName returns the name of the provider this satisfies. Name returns the full name of the provider in the config.

type GraphNodeProviderConsumer Uses

type GraphNodeProviderConsumer interface {
    ProvidedBy() string
    // Set the resolved provider address for this resource.
    SetProvider(string)
}

GraphNodeProviderConsumer is an interface that nodes that require a provider must implement. ProvidedBy must return the name of the provider to use. This may be a provider by type, type.alias or a fully resolved provider name

type GraphNodeProvisioner Uses

type GraphNodeProvisioner interface {
    ProvisionerName() string
}

GraphNodeProvisioner is an interface that nodes that can be a provisioner must implement. The ProvisionerName returned is the name of the provisioner they satisfy.

type GraphNodeProvisionerConsumer Uses

type GraphNodeProvisionerConsumer interface {
    ProvisionedBy() []string
}

GraphNodeProvisionerConsumer is an interface that nodes that require a provisioner must implement. ProvisionedBy must return the name of the provisioner to use.

type GraphNodeReferenceGlobal Uses

type GraphNodeReferenceGlobal interface {
    // Set to true to signal that references and name are fully
    // qualified. See the above docs for more information.
    ReferenceGlobal() bool
}

GraphNodeReferenceGlobal is an interface that can optionally be implemented. If ReferenceGlobal returns true, then the References() and ReferenceableName() must be _fully qualified_ with "module.foo.bar" etc.

This allows a node to reference and be referenced by a specific name that may cross module boundaries. This can be very dangerous so use this wisely.

The primary use case for this is module boundaries (variables coming in).

type GraphNodeReferenceable Uses

type GraphNodeReferenceable interface {
    // ReferenceableName is the name by which this can be referenced.
    // This can be either just the type, or include the field. Example:
    // "aws_instance.bar" or "aws_instance.bar.id".
    ReferenceableName() []string
}

GraphNodeReferenceable must be implemented by any node that represents a Terraform thing that can be referenced (resource, module, etc.).

Even if the thing has no name, this should return an empty list. By implementing this and returning a non-nil result, you say that this CAN be referenced and other methods of referencing may still be possible (such as by path!)

type GraphNodeReferencer Uses

type GraphNodeReferencer interface {
    // References are the list of things that this node references. This
    // can include fields or just the type, just like GraphNodeReferenceable
    // above.
    References() []string
}

GraphNodeReferencer must be implemented by nodes that reference other Terraform items and therefore depend on them.

type GraphNodeResource Uses

type GraphNodeResource interface {
    ResourceAddr() *ResourceAddress
}

GraphNodeResource is implemented by any nodes that represent a resource. The type of operation cannot be assumed, only that this node represents the given resource.

type GraphNodeSubPath Uses

type GraphNodeSubPath interface {
    Path() []string
}

GraphNodeSubPath says that a node is part of a graph with a different path, and the context should be adjusted accordingly.

type GraphNodeSubgraph Uses

type GraphNodeSubgraph interface {
    Subgraph() dag.Grapher
}

GraphNodeSubgraph is an interface a node can implement if it has a larger subgraph that should be walked.

type GraphNodeTargetDownstream Uses

type GraphNodeTargetDownstream interface {
    TargetDownstream(targeted, untargeted *dag.Set) bool
}

GraphNodeTargetDownstream is an interface for graph nodes that need to be remain present under targeting if any of their dependencies are targeted. TargetDownstream is called with the set of vertices that are direct dependencies for the node, and it should return true if the node must remain in the graph in support of those dependencies.

This is used in situations where the dependency edges are representing an ordering relationship but the dependency must still be visited if its dependencies are visited. This is true for outputs, for example, since they must get updated if any of their dependent resources get updated, which would not normally be true if one of their dependencies were targeted.

type GraphNodeTargetable Uses

type GraphNodeTargetable interface {
    SetTargets([]ResourceAddress)
}

GraphNodeTargetable is an interface for graph nodes to implement when they need to be told about incoming targets. This is useful for nodes that need to respect targets as they dynamically expand. Note that the list of targets provided will contain every target provided, and each implementing graph node must filter this list to targets considered relevant.

type GraphSemanticChecker Uses

type GraphSemanticChecker interface {
    Check(*dag.Graph) error
}

GraphSemanticChecker is the interface that semantic checks across the entire Terraform graph implement.

The graph should NOT be modified by the semantic checker.

type GraphTransformer Uses

type GraphTransformer interface {
    Transform(*Graph) error
}

GraphTransformer is the interface that transformers implement. This interface is only for transforms that need entire graph visibility.

func GraphTransformIf Uses

func GraphTransformIf(f func() bool, then GraphTransformer) GraphTransformer

GraphTransformIf is a helper function that conditionally returns a GraphTransformer given. This is useful for calling inline a sequence of transforms without having to split it up into multiple append() calls.

func GraphTransformMulti Uses

func GraphTransformMulti(ts ...GraphTransformer) GraphTransformer

GraphTransformMulti combines multiple graph transformers into a single GraphTransformer that runs all the individual graph transformers.

func TransformProviders Uses

func TransformProviders(providers []string, concrete ConcreteProviderNodeFunc, mod *module.Tree) GraphTransformer

type GraphType Uses

type GraphType byte

GraphType is an enum of the type of graph to create with a Context. The values of the constants may change so they shouldn't be depended on; always use the constant name.

const (
    GraphTypeInvalid GraphType = 0
    GraphTypeLegacy  GraphType = iota
    GraphTypeRefresh
    GraphTypePlan
    GraphTypePlanDestroy
    GraphTypeApply
    GraphTypeInput
    GraphTypeValidate
)

func (GraphType) String Uses

func (i GraphType) String() string

type GraphVertexTransformer Uses

type GraphVertexTransformer interface {
    Transform(dag.Vertex) (dag.Vertex, error)
}

GraphVertexTransformer is an interface that transforms a single Vertex within with graph. This is a specialization of GraphTransformer that makes it easy to do vertex replacement.

The GraphTransformer that runs through the GraphVertexTransformers is VertexTransformer.

type GraphWalker Uses

type GraphWalker interface {
    EnterPath([]string) EvalContext
    ExitPath([]string)
    EnterVertex(dag.Vertex)
    ExitVertex(dag.Vertex, error)
    EnterEvalTree(dag.Vertex, EvalNode) EvalNode
    ExitEvalTree(dag.Vertex, interface{}, error) error
}

GraphWalker is an interface that can be implemented that when used with Graph.Walk will invoke the given callbacks under certain events.

type GraphWalkerPanicwrapper Uses

type GraphWalkerPanicwrapper interface {
    GraphWalker

    // Panic is called when a panic occurs. This will halt the panic from
    // propogating so if the walker wants it to crash still it should panic
    // again. This is called from within a defer so runtime/debug.Stack can
    // be used to get the stack trace of the panic.
    Panic(dag.Vertex, interface{})
}

GrpahWalkerPanicwrapper can be optionally implemented to catch panics that occur while walking the graph. This is not generally recommended since panics should crash Terraform and result in a bug report. However, this is particularly useful for situations like the shadow graph where you don't ever want to cause a panic.

func GraphWalkerPanicwrap Uses

func GraphWalkerPanicwrap(w GraphWalker) GraphWalkerPanicwrapper

GraphWalkerPanicwrap wraps an existing Graphwalker to wrap and swallow the panics. This doesn't lose the panics since the panics are still returned as errors as part of a graph walk.

type Hook Uses

type Hook interface {
    // PreApply and PostApply are called before and after a single
    // resource is applied. The error argument in PostApply is the
    // error, if any, that was returned from the provider Apply call itself.
    PreApply(*InstanceInfo, *InstanceState, *InstanceDiff) (HookAction, error)
    PostApply(*InstanceInfo, *InstanceState, error) (HookAction, error)

    // PreDiff and PostDiff are called before and after a single resource
    // resource is diffed.
    PreDiff(*InstanceInfo, *InstanceState) (HookAction, error)
    PostDiff(*InstanceInfo, *InstanceDiff) (HookAction, error)

    // Provisioning hooks
    //
    // All should be self-explanatory. ProvisionOutput is called with
    // output sent back by the provisioners. This will be called multiple
    // times as output comes in, but each call should represent a line of
    // output. The ProvisionOutput method cannot control whether the
    // hook continues running.
    PreProvisionResource(*InstanceInfo, *InstanceState) (HookAction, error)
    PostProvisionResource(*InstanceInfo, *InstanceState) (HookAction, error)
    PreProvision(*InstanceInfo, string) (HookAction, error)
    PostProvision(*InstanceInfo, string, error) (HookAction, error)
    ProvisionOutput(*InstanceInfo, string, string)

    // PreRefresh and PostRefresh are called before and after a single
    // resource state is refreshed, respectively.
    PreRefresh(*InstanceInfo, *InstanceState) (HookAction, error)
    PostRefresh(*InstanceInfo, *InstanceState) (HookAction, error)

    // PostStateUpdate is called after the state is updated.
    PostStateUpdate(*State) (HookAction, error)

    // PreImportState and PostImportState are called before and after
    // a single resource's state is being improted.
    PreImportState(*InstanceInfo, string) (HookAction, error)
    PostImportState(*InstanceInfo, []*InstanceState) (HookAction, error)
}

Hook is the interface that must be implemented to hook into various parts of Terraform, allowing you to inspect or change behavior at runtime.

There are MANY hook points into Terraform. If you only want to implement some hook points, but not all (which is the likely case), then embed the NilHook into your struct, which implements all of the interface but does nothing. Then, override only the functions you want to implement.

type HookAction Uses

type HookAction byte

HookAction is an enum of actions that can be taken as a result of a hook callback. This allows you to modify the behavior of Terraform at runtime.

const (
    // HookActionContinue continues with processing as usual.
    HookActionContinue HookAction = iota

    // HookActionHalt halts immediately: no more hooks are processed
    // and the action that Terraform was about to take is cancelled.
    HookActionHalt
)

type ImportGraphBuilder Uses

type ImportGraphBuilder struct {
    // ImportTargets are the list of resources to import.
    ImportTargets []*ImportTarget

    // Module is the module to add to the graph. See ImportOpts.Module.
    Module *module.Tree

    // Providers is the list of providers supported.
    Providers []string
}

ImportGraphBuilder implements GraphBuilder and is responsible for building a graph for importing resources into Terraform. This is a much, much simpler graph than a normal configuration graph.

func (*ImportGraphBuilder) Build Uses

func (b *ImportGraphBuilder) Build(path []string) (*Graph, error)

Build builds the graph according to the steps returned by Steps.

func (*ImportGraphBuilder) Steps Uses

func (b *ImportGraphBuilder) Steps() []GraphTransformer

Steps returns the ordered list of GraphTransformers that must be executed to build a complete graph.

type ImportOpts Uses

type ImportOpts struct {
    // Targets are the targets to import
    Targets []*ImportTarget

    // Module is optional, and specifies a config module that is loaded
    // into the graph and evaluated. The use case for this is to provide
    // provider configuration.
    Module *module.Tree
}

ImportOpts are used as the configuration for Import.

type ImportProviderValidateTransformer Uses

type ImportProviderValidateTransformer struct{}

ImportProviderValidateTransformer is a GraphTransformer that goes through the providers in the graph and validates that they only depend on variables.

func (*ImportProviderValidateTransformer) Transform Uses

func (t *ImportProviderValidateTransformer) Transform(g *Graph) error

type ImportStateTransformer Uses

type ImportStateTransformer struct {
    Targets []*ImportTarget
}

ImportStateTransformer is a GraphTransformer that adds nodes to the graph to represent the imports we want to do for resources.

func (*ImportStateTransformer) Transform Uses

func (t *ImportStateTransformer) Transform(g *Graph) error

type ImportTarget Uses

type ImportTarget struct {
    // Addr is the full resource address of the resource to import.
    // Example: "module.foo.aws_instance.bar"
    Addr string

    // ID is the ID of the resource to import. This is resource-specific.
    ID  string

    // Provider string
    Provider string
}

ImportTarget is a single resource to import.

type InputMode Uses

type InputMode byte

InputMode defines what sort of input will be asked for when Input is called on Context.

const (
    // InputModeVar asks for all variables
    InputModeVar InputMode = 1 << iota

    // InputModeVarUnset asks for variables which are not set yet.
    // InputModeVar must be set for this to have an effect.
    InputModeVarUnset

    // InputModeProvider asks for provider variables
    InputModeProvider

    // InputModeStd is the standard operating mode and asks for both variables
    // and providers.
    InputModeStd = InputModeVar | InputModeProvider
)

type InputOpts Uses

type InputOpts struct {
    // Id is a unique ID for the question being asked that might be
    // used for logging or to look up a prior answered question.
    Id  string

    // Query is a human-friendly question for inputting this value.
    Query string

    // Description is a description about what this option is. Be wary
    // that this will probably be in a terminal so split lines as you see
    // necessary.
    Description string

    // Default will be the value returned if no data is entered.
    Default string
}

InputOpts are options for asking for input.

type InstanceDiff Uses

type InstanceDiff struct {
    Attributes     map[string]*ResourceAttrDiff
    Destroy        bool
    DestroyDeposed bool
    DestroyTainted bool

    // Meta is a simple K/V map that is stored in a diff and persisted to
    // plans but otherwise is completely ignored by Terraform core. It is
    // meant to be used for additional data a resource may want to pass through.
    // The value here must only contain Go primitives and collections.
    Meta map[string]interface{}
    // contains filtered or unexported fields
}

InstanceDiff is the diff of a resource from some state to another.

func NewInstanceDiff Uses

func NewInstanceDiff() *InstanceDiff

func (*InstanceDiff) ChangeType Uses

func (d *InstanceDiff) ChangeType() DiffChangeType

ChangeType returns the DiffChangeType represented by the diff for this single instance.

func (*InstanceDiff) Copy Uses

func (d *InstanceDiff) Copy() (*InstanceDiff, error)

func (*InstanceDiff) CopyAttributes Uses

func (d *InstanceDiff) CopyAttributes() map[string]*ResourceAttrDiff

Safely copies the Attributes map

func (*InstanceDiff) DeepCopy Uses

func (d *InstanceDiff) DeepCopy() *InstanceDiff

DeepCopy performs a deep copy of all parts of the InstanceDiff

func (*InstanceDiff) DelAttribute Uses

func (d *InstanceDiff) DelAttribute(key string)

func (*InstanceDiff) Empty Uses

func (d *InstanceDiff) Empty() bool

Empty returns true if this diff encapsulates no changes.

func (*InstanceDiff) Equal Uses

func (d *InstanceDiff) Equal(d2 *InstanceDiff) bool

Equal compares two diffs for exact equality.

This is different from the Same comparison that is supported which checks for operation equality taking into account computed values. Equal instead checks for exact equality.

func (*InstanceDiff) GetAttribute Uses

func (d *InstanceDiff) GetAttribute(key string) (*ResourceAttrDiff, bool)

func (*InstanceDiff) GetAttributesLen Uses

func (d *InstanceDiff) GetAttributesLen() int

func (*InstanceDiff) GetDestroy Uses

func (d *InstanceDiff) GetDestroy() bool

func (*InstanceDiff) GetDestroyDeposed Uses

func (d *InstanceDiff) GetDestroyDeposed() bool

func (*InstanceDiff) GetDestroyTainted Uses

func (d *InstanceDiff) GetDestroyTainted() bool

func (*InstanceDiff) GoString Uses

func (d *InstanceDiff) GoString() string

func (*InstanceDiff) Lock Uses

func (d *InstanceDiff) Lock()

func (*InstanceDiff) RequiresNew Uses

func (d *InstanceDiff) RequiresNew() bool

RequiresNew returns true if the diff requires the creation of a new resource (implying the destruction of the old).

func (*InstanceDiff) Same Uses

func (d *InstanceDiff) Same(d2 *InstanceDiff) (bool, string)

Same checks whether or not two InstanceDiff's are the "same". When we say "same", it is not necessarily exactly equal. Instead, it is just checking that the same attributes are changing, a destroy isn't suddenly happening, etc.

func (*InstanceDiff) SetAttribute Uses

func (d *InstanceDiff) SetAttribute(key string, attr *ResourceAttrDiff)

func (*InstanceDiff) SetDestroy Uses

func (d *InstanceDiff) SetDestroy(b bool)

func (*InstanceDiff) SetDestroyDeposed Uses

func (d *InstanceDiff) SetDestroyDeposed(b bool)

func (*InstanceDiff) SetTainted Uses

func (d *InstanceDiff) SetTainted(b bool)

These methods are properly locked, for use outside other InstanceDiff methods but everywhere else within the terraform package. TODO refactor the locking scheme

func (*InstanceDiff) Unlock Uses

func (d *InstanceDiff) Unlock()

type InstanceInfo Uses

type InstanceInfo struct {
    // Id is a unique name to represent this instance. This is not related
    // to InstanceState.ID in any way.
    Id  string

    // ModulePath is the complete path of the module containing this
    // instance.
    ModulePath []string

    // Type is the resource type of this instance
    Type string
    // contains filtered or unexported fields
}

InstanceInfo is used to hold information about the instance and/or resource being modified.

func (*InstanceInfo) HumanId Uses

func (i *InstanceInfo) HumanId() string

HumanId is a unique Id that is human-friendly and useful for UI elements.

func (*InstanceInfo) ResourceAddress Uses

func (i *InstanceInfo) ResourceAddress() *ResourceAddress

ResourceAddress returns the address of the resource that the receiver is describing.

type InstanceState Uses

type InstanceState struct {
    // A unique ID for this resource. This is opaque to Terraform
    // and is only meant as a lookup mechanism for the providers.
    ID  string `json:"id"`

    // Attributes are basic information about the resource. Any keys here
    // are accessible in variable format within Terraform configurations:
    // ${resourcetype.name.attribute}.
    Attributes map[string]string `json:"attributes"`

    // Ephemeral is used to store any state associated with this instance
    // that is necessary for the Terraform run to complete, but is not
    // persisted to a state file.
    Ephemeral EphemeralState `json:"-"`

    // Meta is a simple K/V map that is persisted to the State but otherwise
    // ignored by Terraform core. It's meant to be used for accounting by
    // external client code. The value here must only contain Go primitives
    // and collections.
    Meta map[string]interface{} `json:"meta"`

    // Tainted is used to mark a resource for recreation.
    Tainted bool `json:"tainted"`
    // contains filtered or unexported fields
}

InstanceState is used to track the unique state information belonging to a given instance.

func (*InstanceState) DeepCopy Uses

func (s *InstanceState) DeepCopy() *InstanceState

func (*InstanceState) Empty Uses

func (s *InstanceState) Empty() bool

func (*InstanceState) Equal Uses

func (s *InstanceState) Equal(other *InstanceState) bool

func (*InstanceState) Lock Uses

func (s *InstanceState) Lock()

func (*InstanceState) MergeDiff Uses

func (s *InstanceState) MergeDiff(d *InstanceDiff) *InstanceState

MergeDiff takes a ResourceDiff and merges the attributes into this resource state in order to generate a new state. This new state can be used to provide updated attribute lookups for variable interpolation.

If the diff attribute requires computing the value, and hence won't be available until apply, the value is replaced with the computeID.

func (*InstanceState) Set Uses

func (s *InstanceState) Set(from *InstanceState)

Copy all the Fields from another InstanceState

func (*InstanceState) String Uses

func (s *InstanceState) String() string

func (*InstanceState) Unlock Uses

func (s *InstanceState) Unlock()

type InstanceType Uses

type InstanceType int

InstanceType is an enum of the various types of instances store in the State

const (
    TypeInvalid InstanceType = iota
    TypePrimary
    TypeTainted
    TypeDeposed
)

func ParseInstanceType Uses

func ParseInstanceType(s string) (InstanceType, error)

func (InstanceType) String Uses

func (i InstanceType) String() string

type Interpolater Uses

type Interpolater struct {
    Operation          walkOperation
    Meta               *ContextMeta
    Module             *module.Tree
    State              *State
    StateLock          *sync.RWMutex
    VariableValues     map[string]interface{}
    VariableValuesLock *sync.Mutex
}

Interpolater is the structure responsible for determining the values for interpolations such as `aws_instance.foo.bar`.

func (*Interpolater) Values Uses

func (i *Interpolater) Values(
    scope *InterpolationScope,
    vars map[string]config.InterpolatedVariable) (map[string]ast.Variable, error)

Values returns the values for all the variables in the given map.

type InterpolationScope Uses

type InterpolationScope struct {
    Path     []string
    Resource *Resource
}

InterpolationScope is the current scope of execution. This is required since some variables which are interpolated are dependent on what we're operating on and where we are.

type LocalTransformer Uses

type LocalTransformer struct {
    Module *module.Tree
}

LocalTransformer is a GraphTransformer that adds all the local values from the configuration to the graph.

func (*LocalTransformer) Transform Uses

func (t *LocalTransformer) Transform(g *Graph) error

type MissingProviderTransformer Uses

type MissingProviderTransformer struct {
    // Providers is the list of providers we support.
    Providers []string

    // Concrete, if set, overrides how the providers are made.
    Concrete ConcreteProviderNodeFunc
}

MissingProviderTransformer is a GraphTransformer that adds nodes for all required providers into the graph. Specifically, it creates provider configuration nodes for all the providers that we support. These are pruned later during an optimization pass.

func (*MissingProviderTransformer) Transform Uses

func (t *MissingProviderTransformer) Transform(g *Graph) error

type MissingProvisionerTransformer Uses

type MissingProvisionerTransformer struct {
    // Provisioners is the list of provisioners we support.
    Provisioners []string
}

MissingProvisionerTransformer is a GraphTransformer that adds nodes for missing provisioners into the graph.

func (*MissingProvisionerTransformer) Transform Uses

func (t *MissingProvisionerTransformer) Transform(g *Graph) error

type MockEvalContext Uses

type MockEvalContext struct {
    StoppedCalled bool
    StoppedValue  <-chan struct{}

    HookCalled bool
    HookHook   Hook
    HookError  error

    InputCalled bool
    InputInput  UIInput

    InitProviderCalled   bool
    InitProviderName     string
    InitProviderProvider ResourceProvider
    InitProviderError    error

    ProviderCalled   bool
    ProviderName     string
    ProviderProvider ResourceProvider

    CloseProviderCalled   bool
    CloseProviderName     string
    CloseProviderProvider ResourceProvider

    ProviderInputCalled bool
    ProviderInputName   string
    ProviderInputConfig map[string]interface{}

    SetProviderInputCalled bool
    SetProviderInputName   string
    SetProviderInputConfig map[string]interface{}

    ConfigureProviderCalled bool
    ConfigureProviderName   string
    ConfigureProviderConfig *ResourceConfig
    ConfigureProviderError  error

    InitProvisionerCalled      bool
    InitProvisionerName        string
    InitProvisionerProvisioner ResourceProvisioner
    InitProvisionerError       error

    ProvisionerCalled      bool
    ProvisionerName        string
    ProvisionerProvisioner ResourceProvisioner

    CloseProvisionerCalled      bool
    CloseProvisionerName        string
    CloseProvisionerProvisioner ResourceProvisioner

    InterpolateCalled       bool
    InterpolateConfig       *config.RawConfig
    InterpolateResource     *Resource
    InterpolateConfigResult *ResourceConfig
    InterpolateError        error

    InterpolateProviderCalled       bool
    InterpolateProviderConfig       *config.ProviderConfig
    InterpolateProviderResource     *Resource
    InterpolateProviderConfigResult *ResourceConfig
    InterpolateProviderError        error

    PathCalled bool
    PathPath   []string

    SetVariablesCalled    bool
    SetVariablesModule    string
    SetVariablesVariables map[string]interface{}

    DiffCalled bool
    DiffDiff   *Diff
    DiffLock   *sync.RWMutex

    StateCalled bool
    StateState  *State
    StateLock   *sync.RWMutex
}

MockEvalContext is a mock version of EvalContext that can be used for tests.

func (*MockEvalContext) CloseProvider Uses

func (c *MockEvalContext) CloseProvider(n string) error

func (*MockEvalContext) CloseProvisioner Uses

func (c *MockEvalContext) CloseProvisioner(n string) error

func (*MockEvalContext) ConfigureProvider Uses

func (c *MockEvalContext) ConfigureProvider(n string, cfg *ResourceConfig) error

func (*MockEvalContext) Diff Uses

func (c *MockEvalContext) Diff() (*Diff, *sync.RWMutex)

func (*MockEvalContext) Hook Uses

func (c *MockEvalContext) Hook(fn func(Hook) (HookAction, error)) error

func (*MockEvalContext) InitProvider Uses

func (c *MockEvalContext) InitProvider(t, n string) (ResourceProvider, error)

func (*MockEvalContext) InitProvisioner Uses

func (c *MockEvalContext) InitProvisioner(n string) (ResourceProvisioner, error)

func (*MockEvalContext) Input Uses

func (c *MockEvalContext) Input() UIInput

func (*MockEvalContext) Interpolate Uses

func (c *MockEvalContext) Interpolate(
    config *config.RawConfig, resource *Resource) (*ResourceConfig, error)

func (*MockEvalContext) InterpolateProvider Uses

func (c *MockEvalContext) InterpolateProvider(
    config *config.ProviderConfig, resource *Resource) (*ResourceConfig, error)

func (*MockEvalContext) Path Uses

func (c *MockEvalContext) Path() []string

func (*MockEvalContext) Provider Uses

func (c *MockEvalContext) Provider(n string) ResourceProvider

func (*MockEvalContext) ProviderInput Uses

func (c *MockEvalContext) ProviderInput(n string) map[string]interface{}

func (*MockEvalContext) Provisioner Uses

func (c *MockEvalContext) Provisioner(n string) ResourceProvisioner

func (*MockEvalContext) SetProviderInput Uses

func (c *MockEvalContext) SetProviderInput(n string, cfg map[string]interface{})

func (*MockEvalContext) SetVariables Uses

func (c *MockEvalContext) SetVariables(n string, vs map[string]interface{})

func (*MockEvalContext) State Uses

func (c *MockEvalContext) State() (*State, *sync.RWMutex)

func (*MockEvalContext) Stopped Uses

func (c *MockEvalContext) Stopped() <-chan struct{}

type MockHook Uses

type MockHook struct {
    sync.Mutex

    PreApplyCalled bool
    PreApplyInfo   *InstanceInfo
    PreApplyDiff   *InstanceDiff
    PreApplyState  *InstanceState
    PreApplyReturn HookAction
    PreApplyError  error

    PostApplyCalled      bool
    PostApplyInfo        *InstanceInfo
    PostApplyState       *InstanceState
    PostApplyError       error
    PostApplyReturn      HookAction
    PostApplyReturnError error
    PostApplyFn          func(*InstanceInfo, *InstanceState, error) (HookAction, error)

    PreDiffCalled bool
    PreDiffInfo   *InstanceInfo
    PreDiffState  *InstanceState
    PreDiffReturn HookAction
    PreDiffError  error

    PostDiffCalled bool
    PostDiffInfo   *InstanceInfo
    PostDiffDiff   *InstanceDiff
    PostDiffReturn HookAction
    PostDiffError  error

    PreProvisionResourceCalled bool
    PreProvisionResourceInfo   *InstanceInfo
    PreProvisionInstanceState  *InstanceState
    PreProvisionResourceReturn HookAction
    PreProvisionResourceError  error

    PostProvisionResourceCalled bool
    PostProvisionResourceInfo   *InstanceInfo
    PostProvisionInstanceState  *InstanceState
    PostProvisionResourceReturn HookAction
    PostProvisionResourceError  error

    PreProvisionCalled        bool
    PreProvisionInfo          *InstanceInfo
    PreProvisionProvisionerId string
    PreProvisionReturn        HookAction
    PreProvisionError         error

    PostProvisionCalled        bool
    PostProvisionInfo          *InstanceInfo
    PostProvisionProvisionerId string
    PostProvisionErrorArg      error
    PostProvisionReturn        HookAction
    PostProvisionError         error

    ProvisionOutputCalled        bool
    ProvisionOutputInfo          *InstanceInfo
    ProvisionOutputProvisionerId string
    ProvisionOutputMessage       string

    PostRefreshCalled bool
    PostRefreshInfo   *InstanceInfo
    PostRefreshState  *InstanceState
    PostRefreshReturn HookAction
    PostRefreshError  error

    PreRefreshCalled bool
    PreRefreshInfo   *InstanceInfo
    PreRefreshState  *InstanceState
    PreRefreshReturn HookAction
    PreRefreshError  error

    PreImportStateCalled bool
    PreImportStateInfo   *InstanceInfo
    PreImportStateId     string
    PreImportStateReturn HookAction
    PreImportStateError  error

    PostImportStateCalled bool
    PostImportStateInfo   *InstanceInfo
    PostImportStateState  []*InstanceState
    PostImportStateReturn HookAction
    PostImportStateError  error

    PostStateUpdateCalled bool
    PostStateUpdateState  *State
    PostStateUpdateReturn HookAction
    PostStateUpdateError  error
}

MockHook is an implementation of Hook that can be used for tests. It records all of its function calls.

func (*MockHook) PostApply Uses

func (h *MockHook) PostApply(n *InstanceInfo, s *InstanceState, e error) (HookAction, error)

func (*MockHook) PostDiff Uses

func (h *MockHook) PostDiff(n *InstanceInfo, d *InstanceDiff) (HookAction, error)

func (*MockHook) PostImportState Uses

func (h *MockHook) PostImportState(info *InstanceInfo, s []*InstanceState) (HookAction, error)

func (*MockHook) PostProvision Uses

func (h *MockHook) PostProvision(n *InstanceInfo, provId string, err error) (HookAction, error)

func (*MockHook) PostProvisionResource Uses

func (h *MockHook) PostProvisionResource(n *InstanceInfo, s *InstanceState) (HookAction, error)

func (*MockHook) PostRefresh Uses

func (h *MockHook) PostRefresh(n *InstanceInfo, s *InstanceState) (HookAction, error)

func (*MockHook) PostStateUpdate Uses

func (h *MockHook) PostStateUpdate(s *State) (HookAction, error)

func (*MockHook) PreApply Uses

func (h *MockHook) PreApply(n *InstanceInfo, s *InstanceState, d *InstanceDiff) (HookAction, error)

func (*MockHook) PreDiff Uses

func (h *MockHook) PreDiff(n *InstanceInfo, s *InstanceState) (HookAction, error)

func (*MockHook) PreImportState Uses

func (h *MockHook) PreImportState(info *InstanceInfo, id string) (HookAction, error)

func (*MockHook) PreProvision Uses

func (h *MockHook) PreProvision(n *InstanceInfo, provId string) (HookAction, error)

func (*MockHook) PreProvisionResource Uses

func (h *MockHook) PreProvisionResource(n *InstanceInfo, s *InstanceState) (HookAction, error)

func (*MockHook) PreRefresh Uses

func (h *MockHook) PreRefresh(n *InstanceInfo, s *InstanceState) (HookAction, error)

func (*MockHook) ProvisionOutput Uses

func (h *MockHook) ProvisionOutput(
    n *InstanceInfo,
    provId string,
    msg string)

type MockResourceProvider Uses

type MockResourceProvider struct {
    sync.Mutex

    // Anything you want, in case you need to store extra data with the mock.
    Meta interface{}

    CloseCalled                    bool
    CloseError                     error
    GetSchemaCalled                bool
    GetSchemaRequest               *ProviderSchemaRequest
    GetSchemaReturn                *ProviderSchema
    GetSchemaReturnError           error
    InputCalled                    bool
    InputInput                     UIInput
    InputConfig                    *ResourceConfig
    InputReturnConfig              *ResourceConfig
    InputReturnError               error
    InputFn                        func(UIInput, *ResourceConfig) (*ResourceConfig, error)
    ApplyCalled                    bool
    ApplyInfo                      *InstanceInfo
    ApplyState                     *InstanceState
    ApplyDiff                      *InstanceDiff
    ApplyFn                        func(*InstanceInfo, *InstanceState, *InstanceDiff) (*InstanceState, error)
    ApplyReturn                    *InstanceState
    ApplyReturnError               error
    ConfigureCalled                bool
    ConfigureConfig                *ResourceConfig
    ConfigureFn                    func(*ResourceConfig) error
    ConfigureReturnError           error
    DiffCalled                     bool
    DiffInfo                       *InstanceInfo
    DiffState                      *InstanceState
    DiffDesired                    *ResourceConfig
    DiffFn                         func(*InstanceInfo, *InstanceState, *ResourceConfig) (*InstanceDiff, error)
    DiffReturn                     *InstanceDiff
    DiffReturnError                error
    RefreshCalled                  bool
    RefreshInfo                    *InstanceInfo
    RefreshState                   *InstanceState
    RefreshFn                      func(*InstanceInfo, *InstanceState) (*InstanceState, error)
    RefreshReturn                  *InstanceState
    RefreshReturnError             error
    ResourcesCalled                bool
    ResourcesReturn                []ResourceType
    ReadDataApplyCalled            bool
    ReadDataApplyInfo              *InstanceInfo
    ReadDataApplyDiff              *InstanceDiff
    ReadDataApplyFn                func(*InstanceInfo, *InstanceDiff) (*InstanceState, error)
    ReadDataApplyReturn            *InstanceState
    ReadDataApplyReturnError       error
    ReadDataDiffCalled             bool
    ReadDataDiffInfo               *InstanceInfo
    ReadDataDiffDesired            *ResourceConfig
    ReadDataDiffFn                 func(*InstanceInfo, *ResourceConfig) (*InstanceDiff, error)
    ReadDataDiffReturn             *InstanceDiff
    ReadDataDiffReturnError        error
    StopCalled                     bool
    StopFn                         func() error
    StopReturnError                error
    DataSourcesCalled              bool
    DataSourcesReturn              []DataSource
    ValidateCalled                 bool
    ValidateConfig                 *ResourceConfig
    ValidateFn                     func(*ResourceConfig) ([]string, []error)
    ValidateReturnWarns            []string
    ValidateReturnErrors           []error
    ValidateResourceFn             func(string, *ResourceConfig) ([]string, []error)
    ValidateResourceCalled         bool
    ValidateResourceType           string
    ValidateResourceConfig         *ResourceConfig
    ValidateResourceReturnWarns    []string
    ValidateResourceReturnErrors   []error
    ValidateDataSourceFn           func(string, *ResourceConfig) ([]string, []error)
    ValidateDataSourceCalled       bool
    ValidateDataSourceType         string
    ValidateDataSourceConfig       *ResourceConfig
    ValidateDataSourceReturnWarns  []string
    ValidateDataSourceReturnErrors []error

    ImportStateCalled      bool
    ImportStateInfo        *InstanceInfo
    ImportStateID          string
    ImportStateReturn      []*InstanceState
    ImportStateReturnError error
    ImportStateFn          func(*InstanceInfo, string) ([]*InstanceState, error)
}

MockResourceProvider implements ResourceProvider but mocks out all the calls for testing purposes.

func (*MockResourceProvider) Apply Uses

func (p *MockResourceProvider) Apply(
    info *InstanceInfo,
    state *InstanceState,
    diff *InstanceDiff) (*InstanceState, error)

func (*MockResourceProvider) Close Uses

func (p *MockResourceProvider) Close() error

func (*MockResourceProvider) Configure Uses

func (p *MockResourceProvider) Configure(c *ResourceConfig) error

func (*MockResourceProvider) DataSources Uses

func (p *MockResourceProvider) DataSources() []DataSource

func (*MockResourceProvider) Diff Uses

func (p *MockResourceProvider) Diff(
    info *InstanceInfo,
    state *InstanceState,
    desired *ResourceConfig) (*InstanceDiff, error)

func (*MockResourceProvider) GetSchema Uses

func (p *MockResourceProvider) GetSchema(req *ProviderSchemaRequest) (*ProviderSchema, error)

func (*MockResourceProvider) ImportState Uses

func (p *MockResourceProvider) ImportState(info *InstanceInfo, id string) ([]*InstanceState, error)

func (*MockResourceProvider) Input Uses

func (p *MockResourceProvider) Input(
    input UIInput, c *ResourceConfig) (*ResourceConfig, error)

func (*MockResourceProvider) ReadDataApply Uses

func (p *MockResourceProvider) ReadDataApply(
    info *InstanceInfo,
    d *InstanceDiff) (*InstanceState, error)

func (*MockResourceProvider) ReadDataDiff Uses

func (p *MockResourceProvider) ReadDataDiff(
    info *InstanceInfo,
    desired *ResourceConfig) (*InstanceDiff, error)

func (*MockResourceProvider) Refresh Uses

func (p *MockResourceProvider) Refresh(
    info *InstanceInfo,
    s *InstanceState) (*InstanceState, error)

func (*MockResourceProvider) Resources Uses

func (p *MockResourceProvider) Resources() []ResourceType

func (*MockResourceProvider) Stop Uses

func (p *MockResourceProvider) Stop() error

func (*MockResourceProvider) Validate Uses

func (p *MockResourceProvider) Validate(c *ResourceConfig) ([]string, []error)

func (*MockResourceProvider) ValidateDataSource Uses

func (p *MockResourceProvider) ValidateDataSource(t string, c *ResourceConfig) ([]string, []error)

func (*MockResourceProvider) ValidateResource Uses

func (p *MockResourceProvider) ValidateResource(t string, c *ResourceConfig) ([]string, []error)

type MockResourceProvisioner Uses

type MockResourceProvisioner struct {
    sync.Mutex
    // Anything you want, in case you need to store extra data with the mock.
    Meta interface{}

    ApplyCalled      bool
    ApplyOutput      UIOutput
    ApplyState       *InstanceState
    ApplyConfig      *ResourceConfig
    ApplyFn          func(*InstanceState, *ResourceConfig) error
    ApplyReturnError error

    ValidateCalled       bool
    ValidateConfig       *ResourceConfig
    ValidateFn           func(c *ResourceConfig) ([]string, []error)
    ValidateReturnWarns  []string
    ValidateReturnErrors []error

    StopCalled      bool
    StopFn          func() error
    StopReturnError error
}

MockResourceProvisioner implements ResourceProvisioner but mocks out all the calls for testing purposes.

func (*MockResourceProvisioner) Apply Uses

func (p *MockResourceProvisioner) Apply(
    output UIOutput,
    state *InstanceState,
    c *ResourceConfig) error

func (*MockResourceProvisioner) Stop Uses

func (p *MockResourceProvisioner) Stop() error

func (*MockResourceProvisioner) Validate Uses

func (p *MockResourceProvisioner) Validate(c *ResourceConfig) ([]string, []error)

type MockUIInput Uses

type MockUIInput struct {
    InputCalled       bool
    InputOpts         *InputOpts
    InputReturnMap    map[string]string
    InputReturnString string
    InputReturnError  error
    InputFn           func(*InputOpts) (string, error)
}

MockUIInput is an implementation of UIInput that can be used for tests.

func (*MockUIInput) Input Uses

func (i *MockUIInput) Input(opts *InputOpts) (string, error)

type MockUIOutput Uses

type MockUIOutput struct {
    sync.Mutex
    OutputCalled  bool
    OutputMessage string
    OutputFn      func(string)
}

MockUIOutput is an implementation of UIOutput that can be used for tests.

func (*MockUIOutput) Output Uses

func (o *MockUIOutput) Output(v string)

type ModuleDiff Uses

type ModuleDiff struct {
    Path      []string
    Resources map[string]*InstanceDiff
    Destroy   bool // Set only by the destroy plan
}

ModuleDiff tracks the differences between resources to apply within a single module.

func (*ModuleDiff) ChangeType Uses

func (d *ModuleDiff) ChangeType() DiffChangeType

ChangeType returns the type of changes that the diff for this module includes.

At a module level, this will only be DiffNone, DiffUpdate, DiffDestroy, or DiffCreate. If an instance within the module has a DiffDestroyCreate then this will register as a DiffCreate for a module.

func (*ModuleDiff) Empty Uses

func (d *ModuleDiff) Empty() bool

Empty returns true if the diff has no changes within this module.

func (*ModuleDiff) Instances Uses

func (d *ModuleDiff) Instances(id string) []*InstanceDiff

Instances returns the instance diffs for the id given. This can return multiple instance diffs if there are counts within the resource.

func (*ModuleDiff) IsRoot Uses

func (d *ModuleDiff) IsRoot() bool

IsRoot says whether or not this module diff is for the root module.

func (*ModuleDiff) String Uses

func (d *ModuleDiff) String() string

String outputs the diff in a long but command-line friendly output format that users can read to quickly inspect a diff.

type ModuleState Uses

type ModuleState struct {
    // Path is the import path from the root module. Modules imports are
    // always disjoint, so the path represents amodule tree
    Path []string `json:"path"`

    // Locals are kept only transiently in-memory, because we can always
    // re-compute them.
    Locals map[string]interface{} `json:"-"`

    // Outputs declared by the module and maintained for each module
    // even though only the root module technically needs to be kept.
    // This allows operators to inspect values at the boundaries.
    Outputs map[string]*OutputState `json:"outputs"`

    // Resources is a mapping of the logically named resource to
    // the state of the resource. Each resource may actually have
    // N instances underneath, although a user only needs to think
    // about the 1:1 case.
    Resources map[string]*ResourceState `json:"resources"`

    // Dependencies are a list of things that this module relies on
    // existing to remain intact. For example: an module may depend
    // on a VPC ID given by an aws_vpc resource.
    //
    // Terraform uses this information to build valid destruction
    // orders and to warn the user if they're destroying a module that
    // another resource depends on.
    //
    // Things can be put into this list that may not be managed by
    // Terraform. If Terraform doesn't find a matching ID in the
    // overall state, then it assumes it isn't managed and doesn't
    // worry about it.
    Dependencies []string `json:"depends_on"`
    // contains filtered or unexported fields
}

ModuleState is used to track all the state relevant to a single module. Previous to Terraform 0.3, all state belonged to the "root" module.

func (*ModuleState) Empty Uses

func (m *ModuleState) Empty() bool

func (*ModuleState) Equal Uses

func (m *ModuleState) Equal(other *ModuleState) bool

Equal tests whether one module state is equal to another.

func (*ModuleState) IsDescendent Uses

func (m *ModuleState) IsDescendent(other *ModuleState) bool

IsDescendent returns true if other is a descendent of this module.

func (*ModuleState) IsRoot Uses

func (m *ModuleState) IsRoot() bool

IsRoot says whether or not this module diff is for the root module.

func (*ModuleState) Lock Uses

func (s *ModuleState) Lock()

func (*ModuleState) Orphans Uses

func (m *ModuleState) Orphans(c *config.Config) []string

Orphans returns a list of keys of resources that are in the State but aren't present in the configuration itself. Hence, these keys represent the state of resources that are orphans.

func (*ModuleState) RemovedOutputs Uses

func (m *ModuleState) RemovedOutputs(c *config.Config) []string

RemovedOutputs returns a list of outputs that are in the State but aren't present in the configuration itself.

func (*ModuleState) String Uses

func (m *ModuleState) String() string

func (*ModuleState) Unlock Uses

func (s *ModuleState) Unlock()

func (*ModuleState) View Uses

func (m *ModuleState) View(id string) *ModuleState

View returns a view with the given resource prefix.

type ModuleVariableTransformer Uses

type ModuleVariableTransformer struct {
    Module *module.Tree

    DisablePrune bool // True if pruning unreferenced should be disabled
}

ModuleVariableTransformer is a GraphTransformer that adds all the variables in the configuration to the graph.

This only adds variables that are referenced by other things in the graph. If a module variable is not referenced, it won't be added to the graph.

func (*ModuleVariableTransformer) Transform Uses

func (t *ModuleVariableTransformer) Transform(g *Graph) error

type NilHook Uses

type NilHook struct{}

NilHook is a Hook implementation that does nothing. It exists only to simplify implementing hooks. You can embed this into your Hook implementation and only implement the functions you are interested in.

func (*NilHook) PostApply Uses

func (*NilHook) PostApply(*InstanceInfo, *InstanceState, error) (HookAction, error)

func (*NilHook) PostDiff Uses

func (*NilHook) PostDiff(*InstanceInfo, *InstanceDiff) (HookAction, error)

func (*NilHook) PostImportState Uses

func (*NilHook) PostImportState(*InstanceInfo, []*InstanceState) (HookAction, error)

func (*NilHook) PostProvision Uses

func (*NilHook) PostProvision(*InstanceInfo, string, error) (HookAction, error)

func (*NilHook) PostProvisionResource Uses

func (*NilHook) PostProvisionResource(*InstanceInfo, *InstanceState) (HookAction, error)

func (*NilHook) PostRefresh Uses

func (*NilHook) PostRefresh(*InstanceInfo, *InstanceState) (HookAction, error)

func (*NilHook) PostStateUpdate Uses

func (*NilHook) PostStateUpdate(*State) (HookAction, error)

func (*NilHook) PreApply Uses

func (*NilHook) PreApply(*InstanceInfo, *InstanceState, *InstanceDiff) (HookAction, error)

func (*NilHook) PreDiff Uses

func (*NilHook) PreDiff(*InstanceInfo, *InstanceState) (HookAction, error)

func (*NilHook) PreImportState Uses

func (*NilHook) PreImportState(*InstanceInfo, string) (HookAction, error)

func (*NilHook) PreProvision Uses

func (*NilHook) PreProvision(*InstanceInfo, string) (HookAction, error)

func (*NilHook) PreProvisionResource Uses

func (*NilHook) PreProvisionResource(*InstanceInfo, *InstanceState) (HookAction, error)

func (*NilHook) PreRefresh Uses

func (*NilHook) PreRefresh(*InstanceInfo, *InstanceState) (HookAction, error)

func (*NilHook) ProvisionOutput Uses

func (*NilHook) ProvisionOutput(
    *InstanceInfo, string, string)

type NodeAbstractCountResource Uses

type NodeAbstractCountResource struct {
    *NodeAbstractResource

    // Validate, if true, will perform the validation for the count.
    // This should only be turned on for the "validate" operation.
    Validate bool
}

NodeAbstractCountResource should be embedded instead of NodeAbstractResource if the resource has a `count` value that needs to be expanded.

The embedder should implement `DynamicExpand` to process the count.

func (*NodeAbstractCountResource) EvalTree Uses

func (n *NodeAbstractCountResource) EvalTree() EvalNode

GraphNodeEvalable

type NodeAbstractProvider Uses

type NodeAbstractProvider struct {
    NameValue string
    PathValue []string

    Config *config.ProviderConfig
}

NodeAbstractProvider represents a provider that has no associated operations. It registers all the common interfaces across operations for providers.

func (*NodeAbstractProvider) AttachProvider Uses

func (n *NodeAbstractProvider) AttachProvider(c *config.ProviderConfig)

GraphNodeAttachProvider

func (*NodeAbstractProvider) DotNode Uses

func (n *NodeAbstractProvider) DotNode(name string, opts *dag.DotOpts) *dag.DotNode

GraphNodeDotter impl.

func (*NodeAbstractProvider) Name Uses

func (n *NodeAbstractProvider) Name() string

func (*NodeAbstractProvider) Path Uses

func (n *NodeAbstractProvider) Path() []string

GraphNodeSubPath

func (*NodeAbstractProvider) ProviderConfig Uses

func (n *NodeAbstractProvider) ProviderConfig() *config.ProviderConfig

GraphNodeProvider

func (*NodeAbstractProvider) ProviderName Uses

func (n *NodeAbstractProvider) ProviderName() string

GraphNodeProvider

func (*NodeAbstractProvider) References Uses

func (n *NodeAbstractProvider) References() []string

GraphNodeReferencer

func (*NodeAbstractProvider) RemoveIfNotTargeted Uses

func (n *NodeAbstractProvider) RemoveIfNotTargeted() bool

RemovableIfNotTargeted

type NodeAbstractResource Uses

type NodeAbstractResource struct {
    Addr *ResourceAddress // Addr is the address for this resource

    Config        *config.Resource // Config is the resource in the config
    ResourceState *ResourceState   // ResourceState is the ResourceState for this

    Targets []ResourceAddress // Set from GraphNodeTargetable

    // The address of the provider this resource will use
    ResolvedProvider string
}

NodeAbstractResource represents a resource that has no associated operations. It registers all the interfaces for a resource that common across multiple operation types.

func (*NodeAbstractResource) AttachResourceConfig Uses

func (n *NodeAbstractResource) AttachResourceConfig(c *config.Resource)

GraphNodeAttachResourceConfig

func (*NodeAbstractResource) AttachResourceState Uses

func (n *NodeAbstractResource) AttachResourceState(s *ResourceState)

GraphNodeAttachResourceState

func (*NodeAbstractResource) DotNode Uses

func (n *NodeAbstractResource) DotNode(name string, opts *dag.DotOpts) *dag.DotNode

GraphNodeDotter impl.

func (*NodeAbstractResource) Name Uses

func (n *NodeAbstractResource) Name() string

func (*NodeAbstractResource) Path Uses

func (n *NodeAbstractResource) Path() []string

GraphNodeSubPath

func (*NodeAbstractResource) ProvidedBy Uses

func (n *NodeAbstractResource) ProvidedBy() string

GraphNodeProviderConsumer

func (*NodeAbstractResource) ProvisionedBy Uses

func (n *NodeAbstractResource) ProvisionedBy() []string

GraphNodeProvisionerConsumer

func (*NodeAbstractResource) ReferenceableName Uses

func (n *NodeAbstractResource) ReferenceableName() []string

GraphNodeReferenceable

func (*NodeAbstractResource) References Uses

func (n *NodeAbstractResource) References() []string

GraphNodeReferencer

func (*NodeAbstractResource) ResourceAddr Uses

func (n *NodeAbstractResource) ResourceAddr() *ResourceAddress

GraphNodeResource, GraphNodeAttachResourceState

func (*NodeAbstractResource) ResourceAddress Uses

func (n *NodeAbstractResource) ResourceAddress() *ResourceAddress

GraphNodeAddressable, TODO: remove, used by target, should unify

func (*NodeAbstractResource) SetProvider Uses

func (n *NodeAbstractResource) SetProvider(p string)

func (*NodeAbstractResource) SetTargets Uses

func (n *NodeAbstractResource) SetTargets(targets []ResourceAddress)

GraphNodeTargetable

func (*NodeAbstractResource) StateReferences Uses

func (n *NodeAbstractResource) StateReferences() []string

StateReferences returns the dependencies to put into the state for this resource.

type NodeApplyableModuleVariable Uses

type NodeApplyableModuleVariable struct {
    PathValue []string
    Config    *config.Variable  // Config is the var in the config
    Value     *config.RawConfig // Value is the value that is set

    Module *module.Tree // Antiquated, want to remove
}

NodeApplyableModuleVariable represents a module variable input during the apply step.

func (*NodeApplyableModuleVariable) EvalTree Uses

func (n *NodeApplyableModuleVariable) EvalTree() EvalNode

GraphNodeEvalable

func (*NodeApplyableModuleVariable) Name Uses

func (n *NodeApplyableModuleVariable) Name() string

func (*NodeApplyableModuleVariable) Path Uses

func (n *NodeApplyableModuleVariable) Path() []string

GraphNodeSubPath

func (*NodeApplyableModuleVariable) ReferenceGlobal Uses

func (n *NodeApplyableModuleVariable) ReferenceGlobal() bool

GraphNodeReferenceGlobal

func (*NodeApplyableModuleVariable) ReferenceableName Uses

func (n *NodeApplyableModuleVariable) ReferenceableName() []string

GraphNodeReferenceable

func (*NodeApplyableModuleVariable) References Uses

func (n *NodeApplyableModuleVariable) References() []string

GraphNodeReferencer

func (*NodeApplyableModuleVariable) RemoveIfNotTargeted Uses

func (n *NodeApplyableModuleVariable) RemoveIfNotTargeted() bool

RemovableIfNotTargeted

type NodeApplyableOutput Uses

type NodeApplyableOutput struct {
    PathValue []string
    Config    *config.Output // Config is the output in the config
}

NodeApplyableOutput represents an output that is "applyable": it is ready to be applied.

func (*NodeApplyableOutput) EvalTree Uses

func (n *NodeApplyableOutput) EvalTree() EvalNode

GraphNodeEvalable

func (*NodeApplyableOutput) Name Uses

func (n *NodeApplyableOutput) Name() string

func (*NodeApplyableOutput) Path Uses

func (n *NodeApplyableOutput) Path() []string

GraphNodeSubPath

func (*NodeApplyableOutput) ReferenceableName Uses

func (n *NodeApplyableOutput) ReferenceableName() []string

GraphNodeReferenceable

func (*NodeApplyableOutput) References Uses

func (n *NodeApplyableOutput) References() []string

GraphNodeReferencer

func (*NodeApplyableOutput) RemoveIfNotTargeted Uses

func (n *NodeApplyableOutput) RemoveIfNotTargeted() bool

RemovableIfNotTargeted

func (*NodeApplyableOutput) TargetDownstream Uses

func (n *NodeApplyableOutput) TargetDownstream(targetedDeps, untargetedDeps *dag.Set) bool

GraphNodeTargetDownstream

type NodeApplyableProvider Uses

type NodeApplyableProvider struct {
    *NodeAbstractProvider
}

NodeApplyableProvider represents a provider during an apply.

func (*NodeApplyableProvider) EvalTree Uses

func (n *NodeApplyableProvider) EvalTree() EvalNode

GraphNodeEvalable

type NodeApplyableResource Uses

type NodeApplyableResource struct {
    *NodeAbstractResource
}

NodeApplyableResource represents a resource that is "applyable": it is ready to be applied and is represented by a diff.

func (*NodeApplyableResource) CreateAddr Uses

func (n *NodeApplyableResource) CreateAddr() *ResourceAddress

GraphNodeCreator

func (*NodeApplyableResource) EvalTree Uses

func (n *NodeApplyableResource) EvalTree() EvalNode

GraphNodeEvalable

func (*NodeApplyableResource) References Uses

func (n *NodeApplyableResource) References() []string

GraphNodeReferencer, overriding NodeAbstractResource

type NodeCountBoundary Uses

type NodeCountBoundary struct{}

NodeCountBoundary fixes any "count boundarie" in the state: resources that are named "foo.0" when they should be named "foo"

func (*NodeCountBoundary) EvalTree Uses

func (n *NodeCountBoundary) EvalTree() EvalNode

GraphNodeEvalable

func (*NodeCountBoundary) Name Uses

func (n *NodeCountBoundary) Name() string

type NodeDestroyResource Uses

type NodeDestroyResource struct {
    *NodeAbstractResource
}

NodeDestroyResource represents a resource that is to be destroyed.

func (*NodeDestroyResource) CreateBeforeDestroy Uses

func (n *NodeDestroyResource) CreateBeforeDestroy() bool

GraphNodeDestroyerCBD

func (*NodeDestroyResource) DestroyAddr Uses

func (n *NodeDestroyResource) DestroyAddr() *ResourceAddress

GraphNodeDestroyer

func (*NodeDestroyResource) DynamicExpand Uses

func (n *NodeDestroyResource) DynamicExpand(ctx EvalContext) (*Graph, error)

GraphNodeDynamicExpandable

func (*NodeDestroyResource) EvalTree Uses

func (n *NodeDestroyResource) EvalTree() EvalNode

GraphNodeEvalable

func (*NodeDestroyResource) ModifyCreateBeforeDestroy Uses

func (n *NodeDestroyResource) ModifyCreateBeforeDestroy(v bool) error

GraphNodeDestroyerCBD

func (*NodeDestroyResource) Name Uses

func (n *NodeDestroyResource) Name() string

func (*NodeDestroyResource) ReferenceableName Uses

func (n *NodeDestroyResource) ReferenceableName() []string

GraphNodeReferenceable, overriding NodeAbstractResource

func (*NodeDestroyResource) References Uses

func (n *NodeDestroyResource) References() []string

GraphNodeReferencer, overriding NodeAbstractResource

type NodeDestroyableDataResource Uses

type NodeDestroyableDataResource struct {
    *NodeAbstractResource
}

NodeDestroyableDataResource represents a resource that is "plannable": it is ready to be planned in order to create a diff.

func (*NodeDestroyableDataResource) EvalTree Uses

func (n *NodeDestroyableDataResource) EvalTree() EvalNode

GraphNodeEvalable

type NodeDestroyableOutput Uses

type NodeDestroyableOutput struct {
    PathValue []string
    Config    *config.Output // Config is the output in the config
}

NodeDestroyableOutput represents an output that is "destroybale": its application will remove the output from the state.

func (*NodeDestroyableOutput) EvalTree Uses

func (n *NodeDestroyableOutput) EvalTree() EvalNode

GraphNodeEvalable

func (*NodeDestroyableOutput) Name Uses

func (n *NodeDestroyableOutput) Name() string

func (*NodeDestroyableOutput) Path Uses

func (n *NodeDestroyableOutput) Path() []string

GraphNodeSubPath

func (*NodeDestroyableOutput) References Uses

func (n *NodeDestroyableOutput) References() []string

GraphNodeReferencer

func (*NodeDestroyableOutput) RemoveIfNotTargeted Uses

func (n *NodeDestroyableOutput) RemoveIfNotTargeted() bool

RemovableIfNotTargeted

func (*NodeDestroyableOutput) TargetDownstream Uses

func (n *NodeDestroyableOutput) TargetDownstream(targetedDeps, untargetedDeps *dag.Set) bool

This will keep the destroy node in the graph if its corresponding output node is also in the destroy graph.

type NodeDisabledProvider Uses

type NodeDisabledProvider struct {
    *NodeAbstractProvider
}

NodeDisabledProvider represents a provider that is disabled. A disabled provider does nothing. It exists to properly set inheritance information for child providers.

func (*NodeDisabledProvider) EvalTree Uses

func (n *NodeDisabledProvider) EvalTree() EvalNode

GraphNodeEvalable

func (*NodeDisabledProvider) Name Uses

func (n *NodeDisabledProvider) Name() string

type NodeLocal Uses

type NodeLocal struct {
    PathValue []string
    Config    *config.Local
}

NodeLocal represents a named local value in a particular module.

Local value nodes only have one operation, common to all walk types: evaluate the result and place it in state.

func (*NodeLocal) EvalTree Uses

func (n *NodeLocal) EvalTree() EvalNode

GraphNodeEvalable

func (*NodeLocal) Name Uses

func (n *NodeLocal) Name() string

func (*NodeLocal) Path Uses

func (n *NodeLocal) Path() []string

GraphNodeSubPath

func (*NodeLocal) ReferenceableName Uses

func (n *NodeLocal) ReferenceableName() []string

GraphNodeReferenceable

func (*NodeLocal) References Uses

func (n *NodeLocal) References() []string

GraphNodeReferencer

func (*NodeLocal) RemoveIfNotTargeted Uses

func (n *NodeLocal) RemoveIfNotTargeted() bool

RemovableIfNotTargeted

type NodeModuleRemoved Uses

type NodeModuleRemoved struct {
    PathValue []string
}

NodeModuleRemoved represents a module that is no longer in the config.

func (*NodeModuleRemoved) EvalTree Uses

func (n *NodeModuleRemoved) EvalTree() EvalNode

GraphNodeEvalable

func (*NodeModuleRemoved) Name Uses

func (n *NodeModuleRemoved) Name() string

func (*NodeModuleRemoved) Path Uses

func (n *NodeModuleRemoved) Path() []string

GraphNodeSubPath

func (*NodeModuleRemoved) ReferenceGlobal Uses

func (n *NodeModuleRemoved) ReferenceGlobal() bool

func (*NodeModuleRemoved) References Uses

func (n *NodeModuleRemoved) References() []string

type NodeOutputOrphan Uses

type NodeOutputOrphan struct {
    OutputName string
    PathValue  []string
}

NodeOutputOrphan represents an output that is an orphan.

func (*NodeOutputOrphan) EvalTree Uses

func (n *NodeOutputOrphan) EvalTree() EvalNode

GraphNodeEvalable

func (*NodeOutputOrphan) Name Uses

func (n *NodeOutputOrphan) Name() string

func (*NodeOutputOrphan) Path Uses

func (n *NodeOutputOrphan) Path() []string

GraphNodeSubPath

func (*NodeOutputOrphan) ReferenceableName Uses

func (n *NodeOutputOrphan) ReferenceableName() []string

GraphNodeReferenceable

type NodePlanDestroyableResource Uses

type NodePlanDestroyableResource struct {
    *NodeAbstractResource
}

NodePlanDestroyableResource represents a resource that is "applyable": it is ready to be applied and is represented by a diff.

func (*NodePlanDestroyableResource) DestroyAddr Uses

func (n *NodePlanDestroyableResource) DestroyAddr() *ResourceAddress

GraphNodeDestroyer

func (*NodePlanDestroyableResource) EvalTree Uses

func (n *NodePlanDestroyableResource) EvalTree() EvalNode

GraphNodeEvalable

type NodePlannableResource Uses

type NodePlannableResource struct {
    *NodeAbstractCountResource
}

NodePlannableResource represents a resource that is "plannable": it is ready to be planned in order to create a diff.

func (*NodePlannableResource) DynamicExpand Uses

func (n *NodePlannableResource) DynamicExpand(ctx EvalContext) (*Graph, error)

GraphNodeDynamicExpandable

type NodePlannableResourceInstance Uses

type NodePlannableResourceInstance struct {
    *NodeAbstractResource
}

NodePlannableResourceInstance represents a _single_ resource instance that is plannable. This means this represents a single count index, for example.

func (*NodePlannableResourceInstance) EvalTree Uses

func (n *NodePlannableResourceInstance) EvalTree() EvalNode

GraphNodeEvalable

type NodePlannableResourceOrphan Uses

type NodePlannableResourceOrphan struct {
    *NodeAbstractResource
}

NodePlannableResourceOrphan represents a resource that is "applyable": it is ready to be applied and is represented by a diff.

func (*NodePlannableResourceOrphan) EvalTree Uses

func (n *NodePlannableResourceOrphan) EvalTree() EvalNode

GraphNodeEvalable

func (*NodePlannableResourceOrphan) Name Uses

func (n *NodePlannableResourceOrphan) Name() string

type NodeProvisioner Uses

type NodeProvisioner struct {
    NameValue string
    PathValue []string

    Config *config.ProviderConfig
}

NodeProvisioner represents a provider that has no associated operations. It registers all the common interfaces across operations for providers.

func (*NodeProvisioner) EvalTree Uses

func (n *NodeProvisioner) EvalTree() EvalNode

GraphNodeEvalable impl.

func (*NodeProvisioner) Name Uses

func (n *NodeProvisioner) Name() string

func (*NodeProvisioner) Path Uses

func (n *NodeProvisioner) Path() []string

GraphNodeSubPath

func (*NodeProvisioner) ProvisionerName Uses

func (n *NodeProvisioner) ProvisionerName() string

GraphNodeProvisioner

type NodeRefreshableDataResource Uses

type NodeRefreshableDataResource struct {
    *NodeAbstractCountResource
}

NodeRefreshableDataResource represents a resource that is "plannable": it is ready to be planned in order to create a diff.

func (*NodeRefreshableDataResource) DynamicExpand Uses

func (n *NodeRefreshableDataResource) DynamicExpand(ctx EvalContext) (*Graph, error)

GraphNodeDynamicExpandable

type NodeRefreshableDataResourceInstance Uses

type NodeRefreshableDataResourceInstance struct {
    *NodeAbstractResource
}

NodeRefreshableDataResourceInstance represents a _single_ resource instance that is refreshable.

func (*NodeRefreshableDataResourceInstance) EvalTree Uses

func (n *NodeRefreshableDataResourceInstance) EvalTree() EvalNode

GraphNodeEvalable

type NodeRefreshableManagedResource Uses

type NodeRefreshableManagedResource struct {
    *NodeAbstractCountResource
}

NodeRefreshableManagedResource represents a resource that is expanabled into NodeRefreshableManagedResourceInstance. Resource count orphans are also added.

func (*NodeRefreshableManagedResource) DynamicExpand Uses

func (n *NodeRefreshableManagedResource) DynamicExpand(ctx EvalContext) (*Graph, error)

GraphNodeDynamicExpandable

type NodeRefreshableManagedResourceInstance Uses

type NodeRefreshableManagedResourceInstance struct {
    *NodeAbstractResource
}

NodeRefreshableManagedResourceInstance represents a resource that is "applyable": it is ready to be applied and is represented by a diff.

func (*NodeRefreshableManagedResourceInstance) DestroyAddr Uses

func (n *NodeRefreshableManagedResourceInstance) DestroyAddr() *ResourceAddress

GraphNodeDestroyer

func (*NodeRefreshableManagedResourceInstance) EvalTree Uses

func (n *NodeRefreshableManagedResourceInstance) EvalTree() EvalNode

GraphNodeEvalable

type NodeRootVariable Uses

type NodeRootVariable struct {
    Config *config.Variable
}

NodeRootVariable represents a root variable input.

func (*NodeRootVariable) Name Uses

func (n *NodeRootVariable) Name() string

func (*NodeRootVariable) ReferenceableName Uses

func (n *NodeRootVariable) ReferenceableName() []string

GraphNodeReferenceable

type NodeValidatableResource Uses

type NodeValidatableResource struct {
    *NodeAbstractCountResource
}

NodeValidatableResource represents a resource that is used for validation only.

func (*NodeValidatableResource) DynamicExpand Uses

func (n *NodeValidatableResource) DynamicExpand(ctx EvalContext) (*Graph, error)

GraphNodeDynamicExpandable

func (*NodeValidatableResource) EvalTree Uses

func (n *NodeValidatableResource) EvalTree() EvalNode

GraphNodeEvalable

type NodeValidatableResourceInstance Uses

type NodeValidatableResourceInstance struct {
    *NodeAbstractResource
}

This represents a _single_ resource instance to validate.

func (*NodeValidatableResourceInstance) EvalTree Uses

func (n *NodeValidatableResourceInstance) EvalTree() EvalNode

GraphNodeEvalable

type NullGraphWalker Uses

type NullGraphWalker struct{}

NullGraphWalker is a GraphWalker implementation that does nothing. This can be embedded within other GraphWalker implementations for easily implementing all the required functions.

func (NullGraphWalker) EnterEvalTree Uses

func (NullGraphWalker) EnterEvalTree(v dag.Vertex, n EvalNode) EvalNode

func (NullGraphWalker) EnterPath Uses

func (NullGraphWalker) EnterPath([]string) EvalContext

func (NullGraphWalker) EnterVertex Uses

func (NullGraphWalker) EnterVertex(dag.Vertex)

func (NullGraphWalker) ExitEvalTree Uses

func (NullGraphWalker) ExitEvalTree(dag.Vertex, interface{}, error) error

func (NullGraphWalker) ExitPath Uses

func (NullGraphWalker) ExitPath([]string)

func (NullGraphWalker) ExitVertex Uses

func (NullGraphWalker) ExitVertex(dag.Vertex, error)

type OrphanOutputTransformer Uses

type OrphanOutputTransformer struct {
    Module *module.Tree // Root module
    State  *State       // State is the root state
}

OrphanOutputTransformer finds the outputs that aren't present in the given config that are in the state and adds them to the graph for deletion.

func (*OrphanOutputTransformer) Transform Uses

func (t *OrphanOutputTransformer) Transform(g *Graph) error

type OrphanResourceCountTransformer Uses

type OrphanResourceCountTransformer struct {
    Concrete ConcreteResourceNodeFunc

    Count int              // Actual count of the resource
    Addr  *ResourceAddress // Addr of the resource to look for orphans
    State *State           // Full global state
}

OrphanResourceCountTransformer is a GraphTransformer that adds orphans for an expanded count to the graph. The determination of this depends on the count argument given.

Orphans are found by comparing the count to what is found in the state. This transform assumes that if an element in the state is within the count bounds given, that it is not an orphan.

func (*OrphanResourceCountTransformer) Transform Uses

func (t *OrphanResourceCountTransformer) Transform(g *Graph) error

type OrphanResourceTransformer Uses

type OrphanResourceTransformer struct {
    Concrete ConcreteResourceNodeFunc

    // State is the global state. We require the global state to
    // properly find module orphans at our path.
    State *State

    // Module is the root module. We'll look up the proper configuration
    // using the graph path.
    Module *module.Tree
}

OrphanResourceTransformer is a GraphTransformer that adds resource orphans to the graph. A resource orphan is a resource that is represented in the state but not in the configuration.

This only adds orphans that have no representation at all in the configuration.

func (*OrphanResourceTransformer) Transform Uses

func (t *OrphanResourceTransformer) Transform(g *Graph) error

type OutputState Uses

type OutputState struct {
    // Sensitive describes whether the output is considered sensitive,
    // which may lead to masking the value on screen in some cases.
    Sensitive bool `json:"sensitive"`
    // Type describes the structure of Value. Valid values are "string",
    // "map" and "list"
    Type string `json:"type"`
    // Value contains the value of the output, in the structure described
    // by the Type field.
    Value interface{} `json:"value"`
    // contains filtered or unexported fields
}

OutputState is used to track the state relevant to a single output.

func (*OutputState) Equal Uses

func (s *OutputState) Equal(other *OutputState) bool

Equal compares two OutputState structures for equality. nil values are considered equal.

func (*OutputState) Lock Uses

func (s *OutputState) Lock()

func (*OutputState) String Uses

func (s *OutputState) String() string

func (*OutputState) Unlock Uses

func (s *OutputState) Unlock()

type OutputTransformer Uses

type OutputTransformer struct {
    Module *module.Tree
}

OutputTransformer is a GraphTransformer that adds all the outputs in the configuration to the graph.

This is done for the apply graph builder even if dependent nodes aren't changing since there is no downside: the state will be available even if the dependent items aren't changing.

func (*OutputTransformer) Transform Uses

func (t *OutputTransformer) Transform(g *Graph) error

type ParentProviderTransformer Uses

type ParentProviderTransformer struct{}

ParentProviderTransformer connects provider nodes to their parents.

This works by finding nodes that are both GraphNodeProviders and GraphNodeSubPath. It then connects the providers to their parent path. The parent provider is always at the root level.

func (*ParentProviderTransformer) Transform Uses

func (t *ParentProviderTransformer) Transform(g *Graph) error

type Plan Uses

type Plan struct {
    // Diff describes the resource actions that must be taken when this
    // plan is applied.
    Diff *Diff

    // Module represents the entire configuration that was present when this
    // plan was created.
    Module *module.Tree

    // State is the Terraform state that was current when this plan was
    // created.
    //
    // It is not allowed to apply a plan that has a stale state, since its
    // diff could be outdated.
    State *State

    // Vars retains the variables that were set when creating the plan, so
    // that the same variables can be applied during apply.
    Vars map[string]interface{}

    // Targets, if non-empty, contains a set of resource address strings that
    // identify graph nodes that were selected as targets for plan.
    //
    // When targets are set, any graph node that is not directly targeted or
    // indirectly targeted via dependencies is excluded from the graph.
    Targets []string

    // TerraformVersion is the version of Terraform that was used to create
    // this plan.
    //
    // It is not allowed to apply a plan created with a different version of
    // Terraform, since the other fields of this structure may be interpreted
    // in different ways between versions.
    TerraformVersion string

    // ProviderSHA256s is a map giving the SHA256 hashes of the exact binaries
    // used as plugins for each provider during plan.
    //
    // These must match between plan and apply to ensure that the diff is
    // correctly interpreted, since different provider versions may have
    // different attributes or attribute value constraints.
    ProviderSHA256s map[string][]byte

    // Backend is the backend that this plan should use and store data with.
    Backend *BackendState

    // Destroy indicates that this plan was created for a full destroy operation
    Destroy bool
    // contains filtered or unexported fields
}

Plan represents a single Terraform execution plan, which contains all the information necessary to make an infrastructure change.

A plan has to contain basically the entire state of the world necessary to make a change: the state, diff, config, backend config, etc. This is so that it can run alone without any other data.

func ReadPlan Uses

func ReadPlan(src io.Reader) (*Plan, error)

ReadPlan reads a plan structure out of a reader in the format that was written by WritePlan.

func (*Plan) Context Uses

func (p *Plan) Context(opts *ContextOpts) (*Context, error)

Context returns a Context with the data encapsulated in this plan.

The following fields in opts are overridden by the plan: Config, Diff, Variables.

If State is not provided, it is set from the plan. If it _is_ provided, it must be Equal to the state stored in plan, but may have a newer serial.

func (*Plan) String Uses

func (p *Plan) String() string

type PlanGraphBuilder Uses

type PlanGraphBuilder struct {
    // Module is the root module for the graph to build.
    Module *module.Tree

    // State is the current state
    State *State

    // Providers is the list of providers supported.
    Providers []string

    // Provisioners is the list of provisioners supported.
    Provisioners []string

    // Targets are resources to target
    Targets []string

    // DisableReduce, if true, will not reduce the graph. Great for testing.
    DisableReduce bool

    // Validate will do structural validation of the graph.
    Validate bool

    // CustomConcrete can be set to customize the node types created
    // for various parts of the plan. This is useful in order to customize
    // the plan behavior.
    CustomConcrete         bool
    ConcreteProvider       ConcreteProviderNodeFunc
    ConcreteResource       ConcreteResourceNodeFunc
    ConcreteResourceOrphan ConcreteResourceNodeFunc
    // contains filtered or unexported fields
}

PlanGraphBuilder implements GraphBuilder and is responsible for building a graph for planning (creating a Terraform Diff).

The primary difference between this graph and others:

* Based on the config since it represents the target state

* Ignores lifecycle options since no lifecycle events occur here. This
  simplifies the graph significantly since complex transforms such as
  create-before-destroy can be completely ignored.

func (*PlanGraphBuilder) Build Uses

func (b *PlanGraphBuilder) Build(path []string) (*Graph, error)

See GraphBuilder

func (*PlanGraphBuilder) Steps Uses

func (b *PlanGraphBuilder) Steps() []GraphTransformer

See GraphBuilder

type PrefixUIInput Uses

type PrefixUIInput struct {
    IdPrefix    string
    QueryPrefix string
    UIInput     UIInput
}

PrefixUIInput is an implementation of UIInput that prefixes the ID with a string, allowing queries to be namespaced.

func (*PrefixUIInput) Input Uses

func (i *PrefixUIInput) Input(opts *InputOpts) (string, error)

type ProviderConfigTransformer Uses

type ProviderConfigTransformer struct {
    Providers []string
    Concrete  ConcreteProviderNodeFunc

    // Module is the module to add resources from.
    Module *module.Tree
    // contains filtered or unexported fields
}

ProviderConfigTransformer adds all provider nodes from the configuration and attaches the configs.

func (*ProviderConfigTransformer) Transform Uses

func (t *ProviderConfigTransformer) Transform(g *Graph) error

type ProviderSchema Uses

type ProviderSchema struct {
    Provider      *configschema.Block
    ResourceTypes map[string]*configschema.Block
    DataSources   map[string]*configschema.Block
}

ProviderSchema represents the schema for a provider's own configuration and the configuration for some or all of its resources and data sources.

The completeness of this structure depends on how it was constructed. When constructed for a configuration, it will generally include only resource types and data sources used by that configuration.

type ProviderSchemaRequest Uses

type ProviderSchemaRequest struct {
    ResourceTypes []string
    DataSources   []string
}

ProviderSchemaRequest is used to describe to a ResourceProvider which aspects of schema are required, when calling the GetSchema method.

type ProviderSchemas Uses

type ProviderSchemas map[string]*ProviderSchema

ProviderSchemas is a map from provider names to provider schemas.

The names in this map are the direct plugin name (e.g. "aws") rather than any alias name (e.g. "aws.foo"), since.

type ProviderTransformer Uses

type ProviderTransformer struct{}

ProviderTransformer is a GraphTransformer that maps resources to providers within the graph. This will error if there are any resources that don't map to proper resources.

func (*ProviderTransformer) Transform Uses

func (t *ProviderTransformer) Transform(g *Graph) error

type ProvisionerTransformer Uses

type ProvisionerTransformer struct{}

ProvisionerTransformer is a GraphTransformer that maps resources to provisioners within the graph. This will error if there are any resources that don't map to proper resources.

func (*ProvisionerTransformer) Transform Uses

func (t *ProvisionerTransformer) Transform(g *Graph) error

type ProvisionerUIOutput Uses

type ProvisionerUIOutput struct {
    Info  *InstanceInfo
    Type  string
    Hooks []Hook
}

ProvisionerUIOutput is an implementation of UIOutput that calls a hook for the output so that the hooks can handle it.

func (*ProvisionerUIOutput) Output Uses

func (o *ProvisionerUIOutput) Output(msg string)

type PruneProviderTransformer Uses

type PruneProviderTransformer struct{}

PruneProviderTransformer removes any providers that are not actually used by anything, and provider proxies. This avoids the provider being initialized and configured. This both saves resources but also avoids errors since configuration may imply initialization which may require auth.

func (*PruneProviderTransformer) Transform Uses

func (t *PruneProviderTransformer) Transform(g *Graph) error

type PruneUnusedValuesTransformer Uses

type PruneUnusedValuesTransformer struct{}

PruneUnusedValuesTransformer is s GraphTransformer that removes local and output values which are not referenced in the graph. Since outputs and locals always need to be evaluated, if they reference a resource that is not available in the state the interpolation could fail.

func (*PruneUnusedValuesTransformer) Transform Uses

func (t *PruneUnusedValuesTransformer) Transform(g *Graph) error

type ReferenceMap Uses

type ReferenceMap struct {
    // contains filtered or unexported fields
}

ReferenceMap is a structure that can be used to efficiently check for references on a graph.

func NewReferenceMap Uses

func NewReferenceMap(vs []dag.Vertex) *ReferenceMap

NewReferenceMap is used to create a new reference map for the given set of vertices.

func (*ReferenceMap) ReferencedBy Uses

func (m *ReferenceMap) ReferencedBy(v dag.Vertex) []dag.Vertex

ReferencedBy returns the list of vertices that reference the vertex passed in.

func (*ReferenceMap) References Uses

func (m *ReferenceMap) References(v dag.Vertex) ([]dag.Vertex, []string)

References returns the list of vertices that this vertex references along with any missing references.

type ReferenceTransformer Uses

type ReferenceTransformer struct{}

ReferenceTransformer is a GraphTransformer that connects all the nodes that reference each other in order to form the proper ordering.

func (*ReferenceTransformer) Transform Uses

func (t *ReferenceTransformer) Transform(g *Graph) error

type RefreshGraphBuilder Uses

type RefreshGraphBuilder struct {
    // Module is the root module for the graph to build.
    Module *module.Tree

    // State is the current state
    State *State

    // Providers is the list of providers supported.
    Providers []string

    // Targets are resources to target
    Targets []string

    // DisableReduce, if true, will not reduce the graph. Great for testing.
    DisableReduce bool

    // Validate will do structural validation of the graph.
    Validate bool
}

RefreshGraphBuilder implements GraphBuilder and is responsible for building a graph for refreshing (updating the Terraform state).

The primary difference between this graph and others:

* Based on the state since it represents the only resources that
  need to be refreshed.

* Ignores lifecycle options since no lifecycle events occur here. This
  simplifies the graph significantly since complex transforms such as
  create-before-destroy can be completely ignored.

func (*RefreshGraphBuilder) Build Uses

func (b *RefreshGraphBuilder) Build(path []string) (*Graph, error)

See GraphBuilder

func (*RefreshGraphBuilder) Steps Uses

func (b *RefreshGraphBuilder) Steps() []GraphTransformer

See GraphBuilder

type RemoteState Uses

type RemoteState struct {
    // Type controls the client we use for the remote state
    Type string `json:"type"`

    // Config is used to store arbitrary configuration that
    // is type specific
    Config map[string]string `json:"config"`
    // contains filtered or unexported fields
}

RemoteState is used to track the information about a remote state store that we push/pull state to.

func (*RemoteState) Empty Uses

func (r *RemoteState) Empty() bool

func (*RemoteState) Equals Uses

func (r *RemoteState) Equals(other *RemoteState) bool

func (*RemoteState) Lock Uses

func (s *RemoteState) Lock()

func (*RemoteState) Unlock Uses

func (s *RemoteState) Unlock()

type RemovableIfNotTargeted Uses

type RemovableIfNotTargeted interface {
    RemoveIfNotTargeted() bool
}

RemovableIfNotTargeted is a special interface for graph nodes that aren't directly addressable, but need to be removed from the graph when they are not targeted. (Nodes that are not directly targeted end up in the set of targeted nodes because something that _is_ targeted depends on them.) The initial use case for this interface is GraphNodeConfigVariable, which was having trouble interpolating for module variables in targeted scenarios that filtered out the resource node being referenced.

type RemovedModuleTransformer Uses

type RemovedModuleTransformer struct {
    Module *module.Tree // root module
    State  *State
}

RemoveModuleTransformer implements GraphTransformer to add nodes indicating when a module was removed from the configuration.

func (*RemovedModuleTransformer) Transform Uses

func (t *RemovedModuleTransformer) Transform(g *Graph) error

type Resource Uses

type Resource struct {
    // These are all used by the new EvalNode stuff.
    Name       string
    Type       string
    CountIndex int

    // These aren't really used anymore anywhere, but we keep them around
    // since we haven't done a proper cleanup yet.
    Id           string
    Info         *InstanceInfo
    Config       *ResourceConfig
    Dependencies []string
    Diff         *InstanceDiff
    Provider     ResourceProvider
    State        *InstanceState
    Provisioners []*ResourceProvisionerConfig
    Flags        ResourceFlag
}

Resource encapsulates a resource, its configuration, its provider, its current state, and potentially a desired diff from the state it wants to reach.

type ResourceAddress Uses

type ResourceAddress struct {
    // Addresses a resource falling somewhere in the module path
    // When specified alone, addresses all resources within a module path
    Path []string

    // Addresses a specific resource that occurs in a list
    Index int

    InstanceType    InstanceType
    InstanceTypeSet bool
    Name            string
    Type            string
    Mode            config.ResourceMode // significant only if InstanceTypeSet
}

ResourceAddress is a way of identifying an individual resource (or, eventually, a subset of resources) within the state. It is used for Targets.

func ParseResourceAddress Uses

func ParseResourceAddress(s string) (*ResourceAddress, error)

func ParseResourceAddressForInstanceDiff Uses

func ParseResourceAddressForInstanceDiff(path []string, key string) (*ResourceAddress, error)

ParseResourceAddressForInstanceDiff creates a ResourceAddress for a resource name as described in a module diff.

For historical reasons a different addressing format is used in this context. The internal format should not be shown in the UI and instead this function should be used to translate to a ResourceAddress and then, where appropriate, use the String method to produce a canonical resource address string for display in the UI.

The given path slice must be empty (or nil) for the root module, and otherwise consist of a sequence of module names traversing down into the module tree. If a non-nil path is provided, the caller must not modify its underlying array after passing it to this function.

func (*ResourceAddress) Contains Uses

func (addr *ResourceAddress) Contains(other *ResourceAddress) bool

Contains returns true if and only if the given node is contained within the receiver.

Containment is defined in terms of the module and resource heirarchy: a resource is contained within its module and any ancestor modules, an indexed resource instance is contained with the unindexed resource, etc.

func (*ResourceAddress) Copy Uses

func (r *ResourceAddress) Copy() *ResourceAddress

Copy returns a copy of this ResourceAddress

func (*ResourceAddress) Equals Uses

func (addr *ResourceAddress) Equals(raw interface{}) bool

Equals returns true if the receiver matches the given address.

The name of this method is a misnomer, since it doesn't test for exact equality. Instead, it tests that the _specified_ parts of each address match, treating any unspecified parts as wildcards.

See also Contains, which takes a more heirarchical approach to comparing addresses.

func (*ResourceAddress) HasResourceSpec Uses

func (r *ResourceAddress) HasResourceSpec() bool

HasResourceSpec returns true if the address has a resource spec, as defined in the documentation:

https://www.terraform.io/docs/internals/resource-addressing.html

In particular, this returns false if the address contains only a module path, thus addressing the entire module.

func (*ResourceAddress) Less Uses

func (addr *ResourceAddress) Less(other *ResourceAddress) bool

Less returns true if and only if the receiver should be sorted before the given address when presenting a list of resource addresses to an end-user.

This sort uses lexicographic sorting for most components, but uses numeric sort for indices, thus causing index 10 to sort after index 9, rather than after index 1.

func (*ResourceAddress) MatchesConfig Uses

func (r *ResourceAddress) MatchesConfig(mod *module.Tree, rc *config.Resource) bool

MatchesConfig returns true if the receiver matches the given configuration resource within the given configuration module.

Since resource configuration blocks represent all of the instances of a multi-instance resource, the index of the address (if any) is not considered.

func (*ResourceAddress) String Uses

func (r *ResourceAddress) String() string

String outputs the address that parses into this address.

func (*ResourceAddress) WholeModuleAddress Uses

func (r *ResourceAddress) WholeModuleAddress() *ResourceAddress

WholeModuleAddress returns the resource address that refers to all resources in the same module as the receiver address.

type ResourceAttrDiff Uses

type ResourceAttrDiff struct {
    Old         string      // Old Value
    New         string      // New Value
    NewComputed bool        // True if new value is computed (unknown currently)
    NewRemoved  bool        // True if this attribute is being removed
    NewExtra    interface{} // Extra information for the provider
    RequiresNew bool        // True if change requires new resource
    Sensitive   bool        // True if the data should not be displayed in UI output
    Type        DiffAttrType
}

ResourceAttrDiff is the diff of a single attribute of a resource.

func (*ResourceAttrDiff) Empty Uses

func (d *ResourceAttrDiff) Empty() bool

Empty returns true if the diff for this attr is neutral

func (*ResourceAttrDiff) GoString Uses

func (d *ResourceAttrDiff) GoString() string

type ResourceConfig Uses

type ResourceConfig struct {
    ComputedKeys []string
    Raw          map[string]interface{}
    Config       map[string]interface{}
    // contains filtered or unexported fields
}

ResourceConfig holds the configuration given for a resource. This is done instead of a raw `map[string]interface{}` type so that rich methods can be added to it to make dealing with it easier.

func NewResourceConfig Uses

func NewResourceConfig(c *config.RawConfig) *ResourceConfig

NewResourceConfig creates a new ResourceConfig from a config.RawConfig.

func (*ResourceConfig) CheckSet Uses

func (c *ResourceConfig) CheckSet(keys []string) []error

CheckSet checks that the given list of configuration keys is properly set. If not, errors are returned for each unset key.

This is useful to be called in the Validate method of a ResourceProvider.

func (*ResourceConfig) DeepCopy Uses

func (c *ResourceConfig) DeepCopy() *ResourceConfig

DeepCopy performs a deep copy of the configuration. This makes it safe to modify any of the structures that are part of the resource config without affecting the original configuration.

func (*ResourceConfig) Equal Uses

func (c *ResourceConfig) Equal(c2 *ResourceConfig) bool

Equal checks the equality of two resource configs.

func (*ResourceConfig) Get Uses

func (c *ResourceConfig) Get(k string) (interface{}, bool)

Get looks up a configuration value by key and returns the value.

The second return value is true if the get was successful. Get will return the raw value if the key is computed, so you should pair this with IsComputed.

func (*ResourceConfig) GetRaw Uses

func (c *ResourceConfig) GetRaw(k string) (interface{}, bool)

GetRaw looks up a configuration value by key and returns the value, from the raw, uninterpolated config.

The second return value is true if the get was successful. Get will not succeed if the value is being computed.

func (*ResourceConfig) IsComputed Uses

func (c *ResourceConfig) IsComputed(k string) bool

IsComputed returns whether the given key is computed or not.

func (*ResourceConfig) IsSet Uses

func (c *ResourceConfig) IsSet(k string) bool

IsSet checks if the key in the configuration is set. A key is set if it has a value or the value is being computed (is unknown currently).

This function should be used rather than checking the keys of the raw configuration itself, since a key may be omitted from the raw configuration if it is being computed.

type ResourceCountTransformer Uses

type ResourceCountTransformer struct {
    Concrete ConcreteResourceNodeFunc

    Count int
    Addr  *ResourceAddress
}

ResourceCountTransformer is a GraphTransformer that expands the count out for a specific resource.

This assumes that the count is already interpolated.

func (*ResourceCountTransformer) Transform Uses

func (t *ResourceCountTransformer) Transform(g *Graph) error

type ResourceFlag Uses

type ResourceFlag byte

ResourceKind specifies what kind of instance we're working with, whether its a primary instance, a tainted instance, or an orphan.

type ResourceProvider Uses

type ResourceProvider interface {

    // ProviderSchema returns the config schema for the main provider
    // configuration, as would appear in a "provider" block in the
    // configuration files.
    //
    // Currently not all providers support schema. Callers must therefore
    // first call Resources and DataSources and ensure that at least one
    // resource or data source has the SchemaAvailable flag set.
    GetSchema(*ProviderSchemaRequest) (*ProviderSchema, error)

    // Input is called to ask the provider to ask the user for input
    // for completing the configuration if necesarry.
    //
    // This may or may not be called, so resource provider writers shouldn't
    // rely on this being available to set some default values for validate
    // later. Example of a situation where this wouldn't be called is if
    // the user is not using a TTY.
    Input(UIInput, *ResourceConfig) (*ResourceConfig, error)

    // Validate is called once at the beginning with the raw configuration
    // (no interpolation done) and can return a list of warnings and/or
    // errors.
    //
    // This is called once with the provider configuration only. It may not
    // be called at all if no provider configuration is given.
    //
    // This should not assume that any values of the configurations are valid.
    // The primary use case of this call is to check that required keys are
    // set.
    Validate(*ResourceConfig) ([]string, []error)

    // Configure configures the provider itself with the configuration
    // given. This is useful for setting things like access keys.
    //
    // This won't be called at all if no provider configuration is given.
    //
    // Configure returns an error if it occurred.
    Configure(*ResourceConfig) error

    // Resources returns all the available resource types that this provider
    // knows how to manage.
    Resources() []ResourceType

    // Stop is called when the provider should halt any in-flight actions.
    //
    // This can be used to make a nicer Ctrl-C experience for Terraform.
    // Even if this isn't implemented to do anything (just returns nil),
    // Terraform will still cleanly stop after the currently executing
    // graph node is complete. However, this API can be used to make more
    // efficient halts.
    //
    // Stop doesn't have to and shouldn't block waiting for in-flight actions
    // to complete. It should take any action it wants and return immediately
    // acknowledging it has received the stop request. Terraform core will
    // automatically not make any further API calls to the provider soon
    // after Stop is called (technically exactly once the currently executing
    // graph nodes are complete).
    //
    // The error returned, if non-nil, is assumed to mean that signaling the
    // stop somehow failed and that the user should expect potentially waiting
    // a longer period of time.
    Stop() error

    // ValidateResource is called once at the beginning with the raw
    // configuration (no interpolation done) and can return a list of warnings
    // and/or errors.
    //
    // This is called once per resource.
    //
    // This should not assume any of the values in the resource configuration
    // are valid since it is possible they have to be interpolated still.
    // The primary use case of this call is to check that the required keys
    // are set and that the general structure is correct.
    ValidateResource(string, *ResourceConfig) ([]string, []error)

    // Apply applies a diff to a specific resource and returns the new
    // resource state along with an error.
    //
    // If the resource state given has an empty ID, then a new resource
    // is expected to be created.
    Apply(
        *InstanceInfo,
        *InstanceState,
        *InstanceDiff) (*InstanceState, error)

    // Diff diffs a resource versus a desired state and returns
    // a diff.
    Diff(
        *InstanceInfo,
        *InstanceState,
        *ResourceConfig) (*InstanceDiff, error)

    // Refresh refreshes a resource and updates all of its attributes
    // with the latest information.
    Refresh(*InstanceInfo, *InstanceState) (*InstanceState, error)

    // ImportState requests that the given resource be imported.
    //
    // The returned InstanceState only requires ID be set. Importing
    // will always call Refresh after the state to complete it.
    //
    // IMPORTANT: InstanceState doesn't have the resource type attached
    // to it. A type must be specified on the state via the Ephemeral
    // field on the state.
    //
    // This function can return multiple states. Normally, an import
    // will map 1:1 to a physical resource. However, some resources map
    // to multiple. For example, an AWS security group may contain many rules.
    // Each rule is represented by a separate resource in Terraform,
    // therefore multiple states are returned.
    ImportState(*InstanceInfo, string) ([]*InstanceState, error)

    // ValidateDataSource is called once at the beginning with the raw
    // configuration (no interpolation done) and can return a list of warnings
    // and/or errors.
    //
    // This is called once per data source instance.
    //
    // This should not assume any of the values in the resource configuration
    // are valid since it is possible they have to be interpolated still.
    // The primary use case of this call is to check that the required keys
    // are set and that the general structure is correct.
    ValidateDataSource(string, *ResourceConfig) ([]string, []error)

    // DataSources returns all of the available data sources that this
    // provider implements.
    DataSources() []DataSource

    // ReadDataDiff produces a diff that represents the state that will
    // be produced when the given data source is read using a later call
    // to ReadDataApply.
    ReadDataDiff(*InstanceInfo, *ResourceConfig) (*InstanceDiff, error)

    // ReadDataApply initializes a data instance using the configuration
    // in a diff produced by ReadDataDiff.
    ReadDataApply(*InstanceInfo, *InstanceDiff) (*InstanceState, error)
}

ResourceProvider is an interface that must be implemented by any resource provider: the thing that creates and manages the resources in a Terraform configuration.

Important implementation note: All returned pointers, such as *ResourceConfig, *InstanceState, *InstanceDiff, etc. must not point to shared data. Terraform is highly parallel and assumes that this data is safe to read/write in parallel so it must be unique references. Note that it is safe to return arguments as results, however.

type ResourceProviderCloser Uses

type ResourceProviderCloser interface {
    Close() error
}

ResourceProviderCloser is an interface that providers that can close connections that aren't needed anymore must implement.

type ResourceProviderError Uses

type ResourceProviderError struct {
    Errors []error
}

ResourceProviderError may be returned when creating a Context if the required providers cannot be satisfied. This error can then be used to format a more useful message for the user.

func (*ResourceProviderError) Error Uses

func (e *ResourceProviderError) Error() string

type ResourceProviderFactory Uses

type ResourceProviderFactory func() (ResourceProvider, error)

ResourceProviderFactory is a function type that creates a new instance of a resource provider.

func ResourceProviderFactoryFixed Uses

func ResourceProviderFactoryFixed(p ResourceProvider) ResourceProviderFactory

ResourceProviderFactoryFixed is a helper that creates a ResourceProviderFactory that just returns some fixed provider.

type ResourceProviderResolver Uses

type ResourceProviderResolver interface {
    // Given a constraint map, return a ResourceProviderFactory for each
    // requested provider. If some or all of the constraints cannot be
    // satisfied, return a non-nil slice of errors describing the problems.
    ResolveProviders(reqd discovery.PluginRequirements) (map[string]ResourceProviderFactory, []error)
}

ResourceProviderResolver is an interface implemented by objects that are able to resolve a given set of resource provider version constraints into ResourceProviderFactory callbacks.

func ResourceProviderResolverFixed Uses

func ResourceProviderResolverFixed(factories map[string]ResourceProviderFactory) ResourceProviderResolver

ResourceProviderResolverFixed returns a ResourceProviderResolver that has a fixed set of provider factories provided by the caller. The returned resolver ignores version constraints entirely and just returns the given factory for each requested provider name.

This function is primarily used in tests, to provide mock providers or in-process providers under test.

type ResourceProviderResolverFunc Uses

type ResourceProviderResolverFunc func(reqd discovery.PluginRequirements) (map[string]ResourceProviderFactory, []error)

ResourceProviderResolverFunc wraps a callback function and turns it into a ResourceProviderResolver implementation, for convenience in situations where a function and its associated closure are sufficient as a resolver implementation.

func (ResourceProviderResolverFunc) ResolveProviders Uses

func (f ResourceProviderResolverFunc) ResolveProviders(reqd discovery.PluginRequirements) (map[string]ResourceProviderFactory, []error)

ResolveProviders implements ResourceProviderResolver by calling the wrapped function.

type ResourceProvisioner Uses

type ResourceProvisioner interface {
    // Validate is called once at the beginning with the raw
    // configuration (no interpolation done) and can return a list of warnings
    // and/or errors.
    //
    // This is called once per resource.
    //
    // This should not assume any of the values in the resource configuration
    // are valid since it is possible they have to be interpolated still.
    // The primary use case of this call is to check that the required keys
    // are set and that the general structure is correct.
    Validate(*ResourceConfig) ([]string, []error)

    // Apply runs the provisioner on a specific resource and returns the new
    // resource state along with an error. Instead of a diff, the ResourceConfig
    // is provided since provisioners only run after a resource has been
    // newly created.
    Apply(UIOutput, *InstanceState, *ResourceConfig) error

    // Stop is called when the provisioner should halt any in-flight actions.
    //
    // This can be used to make a nicer Ctrl-C experience for Terraform.
    // Even if this isn't implemented to do anything (just returns nil),
    // Terraform will still cleanly stop after the currently executing
    // graph node is complete. However, this API can be used to make more
    // efficient halts.
    //
    // Stop doesn't have to and shouldn't block waiting for in-flight actions
    // to complete. It should take any action it wants and return immediately
    // acknowledging it has received the stop request. Terraform core will
    // automatically not make any further API calls to the provider soon
    // after Stop is called (technically exactly once the currently executing
    // graph nodes are complete).
    //
    // The error returned, if non-nil, is assumed to mean that signaling the
    // stop somehow failed and that the user should expect potentially waiting
    // a longer period of time.
    Stop() error
}

ResourceProvisioner is an interface that must be implemented by any resource provisioner: the thing that initializes resources in a Terraform configuration.

type ResourceProvisionerCloser Uses

type ResourceProvisionerCloser interface {
    Close() error
}

ResourceProvisionerCloser is an interface that provisioners that can close connections that aren't needed anymore must implement.

type ResourceProvisionerConfig Uses

type ResourceProvisionerConfig struct {
    Type        string
    Provisioner ResourceProvisioner
    Config      *ResourceConfig
    RawConfig   *config.RawConfig
    ConnInfo    *config.RawConfig
}

ResourceProvisionerConfig is used to pair a provisioner with its provided configuration. This allows us to use singleton instances of each ResourceProvisioner and to keep the relevant configuration instead of instantiating a new Provisioner for each resource.

type ResourceProvisionerFactory Uses

type ResourceProvisionerFactory func() (ResourceProvisioner, error)

ResourceProvisionerFactory is a function type that creates a new instance of a resource provisioner.

type ResourceState Uses

type ResourceState struct {
    // This is filled in and managed by Terraform, and is the resource
    // type itself such as "mycloud_instance". If a resource provider sets
    // this value, it won't be persisted.
    Type string `json:"type"`

    // Dependencies are a list of things that this resource relies on
    // existing to remain intact. For example: an AWS instance might
    // depend on a subnet (which itself might depend on a VPC, and so
    // on).
    //
    // Terraform uses this information to build valid destruction
    // orders and to warn the user if they're destroying a resource that
    // another resource depends on.
    //
    // Things can be put into this list that may not be managed by
    // Terraform. If Terraform doesn't find a matching ID in the
    // overall state, then it assumes it isn't managed and doesn't
    // worry about it.
    Dependencies []string `json:"depends_on"`

    // Primary is the current active instance for this resource.
    // It can be replaced but only after a successful creation.
    // This is the instances on which providers will act.
    Primary *InstanceState `json:"primary"`

    // Deposed is used in the mechanics of CreateBeforeDestroy: the existing
    // Primary is Deposed to get it out of the way for the replacement Primary to
    // be created by Apply. If the replacement Primary creates successfully, the
    // Deposed instance is cleaned up.
    //
    // If there were problems creating the replacement Primary, the Deposed
    // instance and the (now tainted) replacement Primary will be swapped so the
    // tainted replacement will be cleaned up instead.
    //
    // An instance will remain in the Deposed list until it is successfully
    // destroyed and purged.
    Deposed []*InstanceState `json:"deposed"`

    // Provider is used when a resource is connected to a provider with an alias.
    // If this string is empty, the resource is connected to the default provider,
    // e.g. "aws_instance" goes with the "aws" provider.
    // If the resource block contained a "provider" key, that value will be set here.
    Provider string `json:"provider"`
    // contains filtered or unexported fields
}

ResourceState holds the state of a resource that is used so that a provider can find and manage an existing resource as well as for storing attributes that are used to populate variables of child resources.

Attributes has attributes about the created resource that are queryable in interpolation: "${type.id.attr}"

Extra is just extra data that a provider can return that we store for later, but is not exposed in any way to the user.

func (*ResourceState) Equal Uses

func (s *ResourceState) Equal(other *ResourceState) bool

Equal tests whether two ResourceStates are equal.

func (*ResourceState) Lock Uses

func (s *ResourceState) Lock()

func (*ResourceState) String Uses

func (s *ResourceState) String() string

func (*ResourceState) Taint Uses

func (s *ResourceState) Taint()

Taint marks a resource as tainted.

func (*ResourceState) Unlock Uses

func (s *ResourceState) Unlock()

func (*ResourceState) Untaint Uses

func (s *ResourceState) Untaint()

Untaint unmarks a resource as tainted.

type ResourceStateKey Uses

type ResourceStateKey struct {
    Name  string
    Type  string
    Mode  config.ResourceMode
    Index int
}

ResourceStateKey is a structured representation of the key used for the ModuleState.Resources mapping

func ParseResourceStateKey Uses

func ParseResourceStateKey(k string) (*ResourceStateKey, error)

ParseResourceStateKey accepts a key in the format used by ModuleState.Resources and returns a resource name and resource index. In the state, a resource has the format "type.name.index" or "type.name". In the latter case, the index is returned as -1.

func (*ResourceStateKey) Equal Uses

func (rsk *ResourceStateKey) Equal(other *ResourceStateKey) bool

Equal determines whether two ResourceStateKeys are the same

func (*ResourceStateKey) String Uses

func (rsk *ResourceStateKey) String() string

type ResourceType Uses

type ResourceType struct {
    Name       string // Name of the resource, example "instance" (no provider prefix)
    Importable bool   // Whether this resource supports importing

    // SchemaAvailable is set if the provider supports the ProviderSchema,
    // ResourceTypeSchema and DataSourceSchema methods. Although it is
    // included on each resource type, it's actually a provider-wide setting
    // that's smuggled here only because that avoids a breaking change to
    // the plugin protocol.
    SchemaAvailable bool
}

ResourceType is a type of resource that a resource provider can manage.

type RootTransformer Uses

type RootTransformer struct{}

RootTransformer is a GraphTransformer that adds a root to the graph.

func (*RootTransformer) Transform Uses

func (t *RootTransformer) Transform(g *Graph) error

type RootVariableTransformer Uses

type RootVariableTransformer struct {
    Module *module.Tree
}

RootVariableTransformer is a GraphTransformer that adds all the root variables to the graph.

Root variables are currently no-ops but they must be added to the graph since downstream things that depend on them must be able to reach them.

func (*RootVariableTransformer) Transform Uses

func (t *RootVariableTransformer) Transform(g *Graph) error

type Schemas Uses

type Schemas struct {
    Providers ProviderSchemas
}

type SemanticChecker Uses

type SemanticChecker interface {
    Check(*dag.Graph, dag.Vertex) error
}

SemanticChecker is the interface that semantic checks across the Terraform graph implement. Errors are accumulated. Even after an error is returned, child vertices in the graph will still be visited.

The graph should NOT be modified by the semantic checker.

The order in which vertices are visited is left unspecified, so the semantic checks should not rely on that.

type Semaphore Uses

type Semaphore chan struct{}

Semaphore is a wrapper around a channel to provide utility methods to clarify that we are treating the channel as a semaphore

func NewSemaphore Uses

func NewSemaphore(n int) Semaphore

NewSemaphore creates a semaphore that allows up to a given limit of simultaneous acquisitions

func (Semaphore) Acquire Uses

func (s Semaphore) Acquire()

Acquire is used to acquire an available slot. Blocks until available.

func (Semaphore) Release Uses

func (s Semaphore) Release()

Release is used to return a slot. Acquire must be called as a pre-condition.

func (Semaphore) TryAcquire Uses

func (s Semaphore) TryAcquire() bool

TryAcquire is used to do a non-blocking acquire. Returns a bool indicating success

type State Uses

type State struct {
    // Version is the state file protocol version.
    Version int `json:"version"`

    // TFVersion is the version of Terraform that wrote this state.
    TFVersion string `json:"terraform_version,omitempty"`

    // Serial is incremented on any operation that modifies
    // the State file. It is used to detect potentially conflicting
    // updates.
    Serial int64 `json:"serial"`

    // Lineage is set when a new, blank state is created and then
    // never updated. This allows us to determine whether the serials
    // of two states can be meaningfully compared.
    // Apart from the guarantee that collisions between two lineages
    // are very unlikely, this value is opaque and external callers
    // should only compare lineage strings byte-for-byte for equality.
    Lineage string `json:"lineage"`

    // Remote is used to track the metadata required to
    // pull and push state files from a remote storage endpoint.
    Remote *RemoteState `json:"remote,omitempty"`

    // Backend tracks the configuration for the backend in use with
    // this state. This is used to track any changes in the backend
    // configuration.
    Backend *BackendState `json:"backend,omitempty"`

    // Modules contains all the modules in a breadth-first order
    Modules []*ModuleState `json:"modules"`
    // contains filtered or unexported fields
}

State keeps track of a snapshot state-of-the-world that Terraform can use to keep track of what real world resources it is actually managing.

func NewState Uses

func NewState() *State

NewState is used to initialize a blank state

func ReadState Uses

func ReadState(src io.Reader) (*State, error)

ReadState reads a state structure out of a reader in the format that was written by WriteState.

func ReadStateV2 Uses

func ReadStateV2(jsonBytes []byte) (*State, error)

func ReadStateV3 Uses

func ReadStateV3(jsonBytes []byte) (*State, error)

func (*State) Add Uses

func (s *State) Add(fromAddrRaw string, toAddrRaw string, raw interface{}) error

Add adds the item in the state at the given address.

The item can be a ModuleState, ResourceState, or InstanceState. Depending on the item type, the address may or may not be valid. For example, a module cannot be moved to a resource address, however a resource can be moved to a module address (it retains the same name, under that resource).

The item can also be a []*ModuleState, which is the case for nested modules. In this case, Add will expect the zero-index to be the top-most module to add and will only nest children from there. For semantics, this is equivalent to module => module.

The full semantics of Add:

                  ┌───────────────────┬───────────────────┬───────────────────┐
                  │  Module Address   │ Resource Address  │ Instance Address  │
┌─────────────────┼───────────────────┼───────────────────┼───────────────────┤
│   ModuleState   │         ✓         │         x         │         x         │
├─────────────────┼───────────────────┼───────────────────┼───────────────────┤
│  ResourceState  │         ✓         │         ✓         │      maybe*       │
├─────────────────┼───────────────────┼───────────────────┼───────────────────┤
│ Instance State  │         ✓         │         ✓         │         ✓         │
└─────────────────┴───────────────────┴───────────────────┴───────────────────┘

*maybe - Resources can be added at an instance address only if the resource

represents a single instance (primary). Example:
"aws_instance.foo" can be moved to "aws_instance.bar.tainted"

func (*State) AddModule Uses

func (s *State) AddModule(path []string) *ModuleState

AddModule adds the module with the given path to the state.

This should be the preferred method to add module states since it allows us to optimize lookups later as well as control sorting.

func (*State) AddModuleState Uses

func (s *State) AddModuleState(mod *ModuleState)

AddModuleState insert this module state and override any existing ModuleState

func (*State) Children Uses

func (s *State) Children(path []string) []*ModuleState

Children returns the ModuleStates that are direct children of the given path. If the path is "root", for example, then children returned might be "root.child", but not "root.child.grandchild".

func (*State) CompareAges Uses

func (s *State) CompareAges(other *State) (StateAgeComparison, error)

CompareAges compares one state with another for which is "older".

This is a simple check using the state's serial, and is thus only as reliable as the serial itself. In the normal case, only one state exists for a given combination of lineage/serial, but Terraform does not guarantee this and so the result of this method should be used with care.

Returns an integer that is negative if the receiver is older than the argument, positive if the converse, and zero if they are equal. An error is returned if the two states are not of the same lineage, in which case the integer returned has no meaning.

func (*State) DeepCopy Uses

func (s *State) DeepCopy() *State

DeepCopy performs a deep copy of the state structure and returns a new structure.

func (*State) Empty Uses

func (s *State) Empty() bool

Empty returns true if the state is empty.

func (*State) EnsureHasLineage Uses

func (s *State) EnsureHasLineage()

func (*State) Equal Uses

func (s *State) Equal(other *State) bool

Equal tests if one state is equal to another.

func (*State) FromFutureTerraform Uses

func (s *State) FromFutureTerraform() bool

FromFutureTerraform checks if this state was written by a Terraform version from the future.

func (*State) HasResources Uses

func (s *State) HasResources() bool

HasResources returns true if the state contains any resources.

This is similar to !s.Empty, but returns true also in the case where the state has modules but all of them are devoid of resources.

func (*State) Init Uses

func (s *State) Init()

func (*State) IsRemote Uses

func (s *State) IsRemote() bool

IsRemote returns true if State represents a state that exists and is remote.

func (*State) Lock Uses

func (s *State) Lock()

func (*State) MarshalEqual Uses

func (s *State) MarshalEqual(other *State) bool

MarshalEqual is similar to Equal but provides a stronger definition of "equal", where two states are equal if and only if their serialized form is byte-for-byte identical.

This is primarily useful for callers that are trying to save snapshots of state to persistent storage, allowing them to detect when a new snapshot must be taken.

Note that the serial number and lineage are included in the serialized form, so it's the caller's responsibility to properly manage these attributes so that this method is only called on two states that have the same serial and lineage, unless detecting such differences is desired.

func (*State) ModuleByPath Uses

func (s *State) ModuleByPath(path []string) *ModuleState

ModuleByPath is used to lookup the module state for the given path. This should be the preferred lookup mechanism as it allows for future lookup optimizations.

func (*State) ModuleOrphans Uses

func (s *State) ModuleOrphans(path []string, c *config.Config) [][]string

ModuleOrphans returns all the module orphans in this state by returning their full paths. These paths can be used with ModuleByPath to return the actual state.

func (*State) Remove Uses

func (s *State) Remove(addr ...string) error

Remove removes the item in the state at the given address, returning any errors that may have occurred.

If the address references a module state or resource, it will delete all children as well. To check what will be deleted, use a StateFilter first.

func (*State) RootModule Uses

func (s *State) RootModule() *ModuleState

RootModule returns the ModuleState for the root module

func (*State) SameLineage Uses

func (s *State) SameLineage(other *State) bool

SameLineage returns true only if the state given in argument belongs to the same "lineage" of states as the receiver.

func (*State) String Uses

func (s *State) String() string

func (*State) Unlock Uses

func (s *State) Unlock()

func (*State) Validate Uses

func (s *State) Validate() error

Validate validates the integrity of this state file.

Certain properties of the statefile are expected by Terraform in order to behave properly. The core of Terraform will assume that once it receives a State structure that it has been validated. This validation check should be called to ensure that.

If this returns an error, then the user should be notified. The error response will include detailed information on the nature of the error.

type StateAgeComparison Uses

type StateAgeComparison int
const (
    StateAgeEqual         StateAgeComparison = 0
    StateAgeReceiverNewer StateAgeComparison = 1
    StateAgeReceiverOlder StateAgeComparison = -1
)

type StateFilter Uses

type StateFilter struct {
    State *State
}

StateFilter is responsible for filtering and searching a state.

This is a separate struct from State rather than a method on State because StateFilter might create sidecar data structures to optimize filtering on the state.

If you change the State, the filter created is invalid and either Reset should be called or a new one should be allocated. StateFilter will not watch State for changes and do this for you. If you filter after changing the State without calling Reset, the behavior is not defined.

func (*StateFilter) Filter Uses

func (f *StateFilter) Filter(fs ...string) ([]*StateFilterResult, error)

Filter takes the addresses specified by fs and finds all the matches. The values of fs are resource addressing syntax that can be parsed by ParseResourceAddress.

type StateFilterResult Uses

type StateFilterResult struct {
    // Module path of the result
    Path []string

    // Address is the address that can be used to reference this exact result.
    Address string

    // Parent, if non-nil, is a parent of this result. For instances, the
    // parent would be a resource. For resources, the parent would be
    // a module. For modules, this is currently nil.
    Parent *StateFilterResult

    // Value is the actual value. This must be type switched on. It can be
    // any data structures that `State` can hold: `ModuleState`,
    // `ResourceState`, `InstanceState`.
    Value interface{}
}

StateFilterResult is a single result from a filter operation. Filter can match multiple things within a state (module, resource, instance, etc.) and this unifies that.

func (*StateFilterResult) String Uses

func (r *StateFilterResult) String() string

type StateFilterResultSlice Uses

type StateFilterResultSlice []*StateFilterResult

StateFilterResultSlice is a slice of results that implements sort.Interface. The sorting goal is what is most appealing to human output.

func (StateFilterResultSlice) Len Uses

func (s StateFilterResultSlice) Len() int

func (StateFilterResultSlice) Less Uses

func (s StateFilterResultSlice) Less(i, j int) bool

func (StateFilterResultSlice) Swap Uses

func (s StateFilterResultSlice) Swap(i, j int)

type StateTransformer Uses

type StateTransformer struct {
    Concrete ConcreteResourceNodeFunc

    State *State
}

StateTransformer is a GraphTransformer that adds the elements of the state to the graph.

This transform is used for example by the DestroyPlanGraphBuilder to ensure that only resources that are in the state are represented in the graph.

func (*StateTransformer) Transform Uses

func (t *StateTransformer) Transform(g *Graph) error

type TargetsTransformer Uses

type TargetsTransformer struct {
    // List of targeted resource names specified by the user
    Targets []string

    // List of parsed targets, provided by callers like ResourceCountTransform
    // that already have the targets parsed
    ParsedTargets []ResourceAddress

    // If set, the index portions of resource addresses will be ignored
    // for comparison. This is used when transforming a graph where
    // counted resources have not yet been expanded, since otherwise
    // the unexpanded nodes (which never have indices) would not match.
    IgnoreIndices bool

    // Set to true when we're in a `terraform destroy` or a
    // `terraform plan -destroy`
    Destroy bool
}

TargetsTransformer is a GraphTransformer that, when the user specifies a list of resources to target, limits the graph to only those resources and their dependencies.

func (*TargetsTransformer) Transform Uses

func (t *TargetsTransformer) Transform(g *Graph) error

type TransitiveReductionTransformer Uses

type TransitiveReductionTransformer struct{}

TransitiveReductionTransformer is a GraphTransformer that performs finds the transitive reduction of the graph. For a definition of transitive reduction, see Wikipedia.

func (*TransitiveReductionTransformer) Transform Uses

func (t *TransitiveReductionTransformer) Transform(g *Graph) error

type UIInput Uses

type UIInput interface {
    Input(*InputOpts) (string, error)
}

UIInput is the interface that must be implemented to ask for input from this user. This should forward the request to wherever the user inputs things to ask for values.

type UIOutput Uses

type UIOutput interface {
    Output(string)
}

UIOutput is the interface that must be implemented to output data to the end user.

type UnorderedSemanticCheckRunner Uses

type UnorderedSemanticCheckRunner struct {
    Checks []SemanticChecker
}

UnorderedSemanticCheckRunner is an implementation of GraphSemanticChecker that runs a list of SemanticCheckers against the vertices of the graph in no specified order.

func (*UnorderedSemanticCheckRunner) Check Uses

func (sc *UnorderedSemanticCheckRunner) Check(g *dag.Graph) error

type VertexTransformer Uses

type VertexTransformer struct {
    Transforms []GraphVertexTransformer
}

VertexTransformer is a GraphTransformer that transforms vertices using the GraphVertexTransformers. The Transforms are run in sequential order. If a transform replaces a vertex then the next transform will see the new vertex.

func (*VertexTransformer) Transform Uses

func (t *VertexTransformer) Transform(g *Graph) error

Package terraform imports 45 packages (graph) and is imported by 4574 packages. Updated 2018-04-10. Refresh now. Tools for package owners.