terraform

package
v0.7.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2016 License: MPL-2.0 Imports: 30 Imported by: 0

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

View Source
const RootModuleName = "root"

RootModuleName is the name given to the root module implicitly.

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

The main version number that is being run at the moment.

View Source
const VersionPrerelease = "rc1"

A pre-release marker for the version. If this is "" (empty string) then it means that it is a final release. Otherwise, this is a pre-release such as "dev" (in development), "beta", "rc1", etc.

Variables ΒΆ

View Source
var RootModulePath = []string{RootModuleName}

RootModulePath is the path for the root module.

View Source
var SemVersion = version.Must(version.NewVersion(Version))

SemVersion is an instance of version.Version. This has the secondary benefit of verifying during tests and init time that our version is a proper semantic version, which should always be the case.

Functions ΒΆ

func Eval ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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 ΒΆ

func GraphDot(g *Graph, opts *GraphDotOpts) (string, error)

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

func ParseResourceIndex ΒΆ added in v0.5.0

func ParseResourceIndex(s string) (int, error)

func ParseResourcePath ΒΆ added in v0.5.0

func ParseResourcePath(s string) []string

func PathCacheKey ΒΆ added in v0.4.0

func PathCacheKey(path []string) string

PathCacheKey returns a cache key for a module path.

TODO: test

func ProviderHasDataSource ΒΆ

func ProviderHasDataSource(p ResourceProvider, n string) bool

func ProviderHasResource ΒΆ

func ProviderHasResource(p ResourceProvider, n string) bool

func ReadStateV1 ΒΆ added in v0.3.0

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

func WritePlan ΒΆ

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

WritePlan writes a plan somewhere in a binary format.

func WriteState ΒΆ

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

WriteState writes a state somewhere in a binary format.

Types ΒΆ

type AddOutputOrphanTransformer ΒΆ added in v0.5.0

type AddOutputOrphanTransformer struct {
	State *State
}

AddOutputOrphanTransformer is a transformer that adds output orphans to the graph. Output orphans are outputs that are no longer in the configuration and therefore need to be removed from the state.

func (*AddOutputOrphanTransformer) Transform ΒΆ added in v0.5.0

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

type BasicGraphBuilder ΒΆ added in v0.4.0

type BasicGraphBuilder struct {
	Steps    []GraphTransformer
	Validate bool
}

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 ΒΆ added in v0.4.0

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

type BuiltinEvalContext ΒΆ added in v0.4.0

type BuiltinEvalContext struct {
	// 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

	Hooks               []Hook
	InputValue          UIInput
	Providers           map[string]ResourceProviderFactory
	ProviderCache       map[string]ResourceProvider
	ProviderConfigCache map[string]*ResourceConfig
	ProviderInputConfig map[string]map[string]interface{}
	ProviderLock        *sync.Mutex
	Provisioners        map[string]ResourceProvisionerFactory
	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 ΒΆ added in v0.6.0

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

func (*BuiltinEvalContext) CloseProvisioner ΒΆ added in v0.6.0

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

func (*BuiltinEvalContext) ConfigureProvider ΒΆ added in v0.4.0

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

func (*BuiltinEvalContext) Diff ΒΆ added in v0.4.0

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

func (*BuiltinEvalContext) Hook ΒΆ added in v0.4.0

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

func (*BuiltinEvalContext) InitProvider ΒΆ added in v0.4.0

func (ctx *BuiltinEvalContext) InitProvider(n string) (ResourceProvider, error)

func (*BuiltinEvalContext) InitProvisioner ΒΆ added in v0.4.0

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

func (*BuiltinEvalContext) Input ΒΆ added in v0.4.0

func (ctx *BuiltinEvalContext) Input() UIInput

func (*BuiltinEvalContext) Interpolate ΒΆ added in v0.4.0

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

func (*BuiltinEvalContext) ParentProviderConfig ΒΆ added in v0.4.0

func (ctx *BuiltinEvalContext) ParentProviderConfig(n string) *ResourceConfig

func (*BuiltinEvalContext) Path ΒΆ added in v0.4.0

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

func (*BuiltinEvalContext) Provider ΒΆ added in v0.4.0

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

func (*BuiltinEvalContext) ProviderInput ΒΆ added in v0.4.0

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

func (*BuiltinEvalContext) Provisioner ΒΆ added in v0.4.0

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

func (*BuiltinEvalContext) SetProviderConfig ΒΆ added in v0.4.1

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

func (*BuiltinEvalContext) SetProviderInput ΒΆ added in v0.4.0

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

func (*BuiltinEvalContext) SetVariables ΒΆ added in v0.4.0

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

func (*BuiltinEvalContext) State ΒΆ added in v0.4.0

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

type BuiltinGraphBuilder ΒΆ added in v0.4.0

type BuiltinGraphBuilder struct {
	// Root is the root module of the graph to build.
	Root *module.Tree

	// Diff is the diff. The proper module diffs will be looked up.
	Diff *Diff

	// State is the global state. The proper module states will be looked
	// up by graph path.
	State *State

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

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

	// Targets is the user-specified list of resources to target.
	Targets []string

	// Destroy is set to true when we're in a `terraform destroy` or a
	// `terraform plan -destroy`
	Destroy bool

	// Determines whether the GraphBuilder should perform graph validation before
	// returning the Graph. Generally you want this to be done, except when you'd
	// like to inspect a problematic graph.
	Validate bool

	// Verbose is set to true when the graph should be built "worst case",
	// skipping any prune steps. This is used for early cycle detection during
	// Validate and for manual inspection via `terraform graph -verbose`.
	Verbose bool
}

BuiltinGraphBuilder is responsible for building the complete graph that Terraform uses for execution. It is an opinionated builder that defines the step order required to build a complete graph as is used and expected by Terraform.

If you require a custom graph, you'll have to build it up manually on your own by building a new GraphBuilder implementation.

func (*BuiltinGraphBuilder) Build ΒΆ added in v0.4.0

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

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

func (*BuiltinGraphBuilder) Steps ΒΆ added in v0.4.0

func (b *BuiltinGraphBuilder) Steps(path []string) []GraphTransformer

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

type CallbackUIOutput ΒΆ added in v0.3.0

type CallbackUIOutput struct {
	OutputFn func(string)
}

func (*CallbackUIOutput) Output ΒΆ added in v0.4.0

func (o *CallbackUIOutput) Output(v string)

type CloseProviderTransformer ΒΆ added in v0.6.0

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 ΒΆ added in v0.6.0

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

type CloseProvisionerTransformer ΒΆ added in v0.6.0

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 ΒΆ added in v0.6.0

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

type ConfigTransformer ΒΆ added in v0.4.0

type ConfigTransformer struct {
	Module *module.Tree
}

ConfigTransformer is a GraphTransformer that adds the configuration to the graph. The module used to configure this transformer must be the root module. We'll look up the child module by the Path in the Graph.

func (*ConfigTransformer) Transform ΒΆ added in v0.4.0

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

type Context ΒΆ

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 ΒΆ

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 ΒΆ

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

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

In addition to returning the resulting state, this context is updated with the latest state.

func (*Context) Graph ΒΆ

func (c *Context) Graph(g *ContextGraphOpts) (*Graph, error)

Graph returns the graph for this config.

func (*Context) Import ΒΆ

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 ΒΆ added in v0.3.0

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) Module ΒΆ added in v0.4.0

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

Module returns the module tree associated with this context.

func (*Context) Plan ΒΆ

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 ΒΆ

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 will be returned and will potentially be partially updated.

func (*Context) SetVariable ΒΆ added in v0.4.0

func (c *Context) SetVariable(k, v string)

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

func (*Context) Stop ΒΆ

func (c *Context) Stop()

Stop stops the running task.

Stop will block until the task completes.

func (*Context) Validate ΒΆ

func (c *Context) Validate() ([]string, []error)

Validate validates the configuration and returns any warnings or errors.

func (*Context) Variables ΒΆ added in v0.4.0

func (c *Context) Variables() map[string]string

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 ΒΆ added in v0.5.0

type ContextGraphOpts struct {
	Validate bool
	Verbose  bool
}

type ContextGraphWalker ΒΆ added in v0.4.0

type ContextGraphWalker struct {
	NullGraphWalker

	// Configurable values
	Context   *Context
	Operation walkOperation

	// 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 ΒΆ added in v0.4.0

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

func (*ContextGraphWalker) EnterPath ΒΆ added in v0.5.0

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

func (*ContextGraphWalker) ExitEvalTree ΒΆ added in v0.4.0

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

type ContextOpts ΒΆ

type ContextOpts struct {
	Destroy            bool
	Diff               *Diff
	Hooks              []Hook
	Module             *module.Tree
	Parallelism        int
	State              *State
	StateFutureAllowed bool
	Providers          map[string]ResourceProviderFactory
	Provisioners       map[string]ResourceProvisionerFactory
	Targets            []string
	Variables          map[string]string

	UIInput UIInput
}

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

type CreateBeforeDestroyTransformer ΒΆ added in v0.4.0

type CreateBeforeDestroyTransformer struct{}

CreateBeforeDestroyTransformer is a GraphTransformer that modifies the destroys of some nodes so that the creation happens before the destroy.

func (*CreateBeforeDestroyTransformer) Transform ΒΆ added in v0.4.0

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

type DataSource ΒΆ

type DataSource struct {
	Name string
}

DataSource is a data source that a resource provider implements.

type DeposedTransformer ΒΆ added in v0.4.0

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
}

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

func (*DeposedTransformer) Transform ΒΆ added in v0.4.0

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

type DestroyTransformer ΒΆ added in v0.4.0

type DestroyTransformer struct {
	FullDestroy bool
}

DestroyTransformer is a GraphTransformer that creates the destruction nodes for things that _might_ be destroyed.

func (*DestroyTransformer) Transform ΒΆ added in v0.4.0

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

type Diff ΒΆ

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

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

func (*Diff) AddModule ΒΆ added in v0.3.0

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) Empty ΒΆ

func (d *Diff) Empty() bool

Empty returns true if the diff has no changes.

func (*Diff) ModuleByPath ΒΆ added in v0.3.0

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) RootModule ΒΆ added in v0.3.0

func (d *Diff) RootModule() *ModuleDiff

RootModule returns the ModuleState for the root module

func (*Diff) String ΒΆ

func (d *Diff) String() string

type DiffAttrType ΒΆ

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 ΒΆ added in v0.3.0

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
)

type DisableProviderTransformer ΒΆ added in v0.4.1

type DisableProviderTransformer struct{}

DisableProviderTransformer "disables" any providers that are only depended on by modules.

func (*DisableProviderTransformer) Transform ΒΆ added in v0.4.1

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

type EphemeralState ΒΆ added in v0.3.0

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 ΒΆ

func (e *EphemeralState) DeepCopy() *EphemeralState

type EvalApply ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

TODO: test

type EvalApplyPost ΒΆ added in v0.4.0

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

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

func (*EvalApplyPost) Eval ΒΆ added in v0.4.0

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

TODO: test

type EvalApplyProvisioners ΒΆ added in v0.4.0

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

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 ΒΆ added in v0.4.0

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

TODO: test

type EvalBuildProviderConfig ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

type EvalCheckPreventDestroy ΒΆ added in v0.5.0

type EvalCheckPreventDestroy struct {
	Resource *config.Resource
	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 ΒΆ added in v0.5.0

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

type EvalClearPrimaryState ΒΆ added in v0.4.0

type EvalClearPrimaryState struct {
	Name string
}

EvalClearPrimaryState is an EvalNode implementation that clears the primary instance from a resource state.

func (*EvalClearPrimaryState) Eval ΒΆ added in v0.4.0

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

type EvalCloseProvider ΒΆ added in v0.6.0

type EvalCloseProvider struct {
	Name string
}

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

func (*EvalCloseProvider) Eval ΒΆ added in v0.6.0

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

type EvalCloseProvisioner ΒΆ added in v0.6.0

type EvalCloseProvisioner struct {
	Name string
}

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

func (*EvalCloseProvisioner) Eval ΒΆ added in v0.6.0

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

type EvalCompareDiff ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

TODO: test

type EvalConfigProvider ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

type EvalContext ΒΆ added in v0.4.0

type EvalContext interface {
	// 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 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(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
	SetProviderConfig(string, *ResourceConfig) error
	ParentProviderConfig(string) *ResourceConfig

	// 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)

	// 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 EvalCountFixZeroOneBoundary ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

TODO: test

type EvalDeleteOutput ΒΆ added in v0.5.0

type EvalDeleteOutput struct {
	Name string
}

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

func (*EvalDeleteOutput) Eval ΒΆ added in v0.5.0

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

TODO: test

type EvalDeposeState ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

TODO: test

type EvalDiff ΒΆ added in v0.4.0

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

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

func (*EvalDiff) Eval ΒΆ added in v0.4.0

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

TODO: test

type EvalDiffDestroy ΒΆ added in v0.4.0

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

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

func (*EvalDiffDestroy) Eval ΒΆ added in v0.4.0

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

TODO: test

type EvalDiffDestroyModule ΒΆ added in v0.4.0

type EvalDiffDestroyModule struct {
	Path []string
}

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

func (*EvalDiffDestroyModule) Eval ΒΆ added in v0.4.0

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

TODO: test

type EvalEarlyExitError ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

func (EvalEarlyExitError) Error() string

type EvalFilterDiff ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

type EvalGetProvider ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

type EvalGetProvisioner ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

type EvalIf ΒΆ added in v0.4.0

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

EvalIf is an EvalNode that is a conditional.

func (*EvalIf) Eval ΒΆ added in v0.4.0

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

TODO: test

type EvalIgnoreChanges ΒΆ added in v0.6.4

type EvalIgnoreChanges struct {
	Resource      *config.Resource
	Diff          **InstanceDiff
	WasChangeType *DiffChangeType
}

EvalIgnoreChanges is an EvalNode implementation that removes diff attributes if their name matches names provided by the resource's IgnoreChanges lifecycle.

func (*EvalIgnoreChanges) Eval ΒΆ added in v0.6.4

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

type EvalImportState ΒΆ

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 ΒΆ

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

TODO: test

type EvalImportStateVerify ΒΆ

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 ΒΆ

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

TODO: test

type EvalInitProvider ΒΆ added in v0.4.0

type EvalInitProvider struct {
	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 ΒΆ added in v0.4.0

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

type EvalInitProvisioner ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

type EvalInputProvider ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

type EvalInstanceInfo ΒΆ added in v0.4.0

type EvalInstanceInfo struct {
	Info *InstanceInfo
}

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

func (*EvalInstanceInfo) Eval ΒΆ added in v0.4.0

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

TODO: test

type EvalInterpolate ΒΆ added in v0.4.0

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

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

func (*EvalInterpolate) Eval ΒΆ added in v0.4.0

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

type EvalNode ΒΆ added in v0.4.0

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 ΒΆ added in v0.6.0

func CloseProviderEvalTree(n string) EvalNode

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

func EvalFilter ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

func ProviderEvalTree(n string, config *config.RawConfig) EvalNode

ProviderEvalTree returns the evaluation tree for initializing and configuring providers.

type EvalNodeFilterFunc ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

func EvalNodeFilterOp(op walkOperation) EvalNodeFilterFunc

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

type EvalNodeFilterable ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

type EvalNoop struct{}

EvalNoop is an EvalNode that does nothing.

func (EvalNoop) Eval ΒΆ added in v0.4.0

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

type EvalOpFilter ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

TODO: test

func (*EvalOpFilter) IncludeInOp ΒΆ added in v0.4.0

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

EvalNodeOpFilterable impl.

type EvalReadDataApply ΒΆ

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 ΒΆ

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

type EvalReadDataDiff ΒΆ

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 ΒΆ

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

type EvalReadDiff ΒΆ added in v0.4.0

type EvalReadDiff struct {
	Name string
	Diff **InstanceDiff
}

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

func (*EvalReadDiff) Eval ΒΆ added in v0.4.0

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

type EvalReadState ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

type EvalReadStateDeposed ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

type EvalRefresh ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

TODO: test

type EvalRequireState ΒΆ added in v0.4.0

type EvalRequireState struct {
	State **InstanceState
}

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

func (*EvalRequireState) Eval ΒΆ added in v0.4.0

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

type EvalReturnError ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

type EvalSequence ΒΆ added in v0.4.0

type EvalSequence struct {
	Nodes []EvalNode
}

EvalSequence is an EvalNode that evaluates in sequence.

func (*EvalSequence) Eval ΒΆ added in v0.4.0

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

func (*EvalSequence) Filter ΒΆ added in v0.4.0

func (n *EvalSequence) Filter(fn EvalNodeFilterFunc)

EvalNodeFilterable impl.

type EvalSetProviderConfig ΒΆ added in v0.4.1

type EvalSetProviderConfig struct {
	Provider string
	Config   **ResourceConfig
}

EvalSetProviderConfig sets the parent configuration for a provider without configuring that provider, validating it, etc.

func (*EvalSetProviderConfig) Eval ΒΆ added in v0.4.1

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

type EvalSetVariables ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

TODO: test

type EvalTypeCheckVariable ΒΆ added in v0.6.15

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).

Currently since the type system is simple, we currently do not make use of the values since it is only valid to pass string values. The structure is in place for extension of the type system, however.

func (*EvalTypeCheckVariable) Eval ΒΆ added in v0.6.15

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

type EvalUndeposeState ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

TODO: test

type EvalUpdateStateHook ΒΆ added in v0.4.0

type EvalUpdateStateHook struct{}

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

func (*EvalUpdateStateHook) Eval ΒΆ added in v0.4.0

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

type EvalValidateCount ΒΆ added in v0.4.0

type EvalValidateCount struct {
	Resource *config.Resource
}

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

func (*EvalValidateCount) Eval ΒΆ added in v0.4.0

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

TODO: test

type EvalValidateError ΒΆ added in v0.4.0

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

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

func (*EvalValidateError) Error ΒΆ added in v0.4.0

func (e *EvalValidateError) Error() string

type EvalValidateProvider ΒΆ added in v0.4.0

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

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

func (*EvalValidateProvider) Eval ΒΆ added in v0.4.0

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

type EvalValidateProvisioner ΒΆ added in v0.4.0

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

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

func (*EvalValidateProvisioner) Eval ΒΆ added in v0.4.0

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

type EvalValidateResource ΒΆ added in v0.4.0

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

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

func (*EvalValidateResource) Eval ΒΆ added in v0.4.0

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

type EvalVariableBlock ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

TODO: test

type EvalWriteDiff ΒΆ added in v0.4.0

type EvalWriteDiff struct {
	Name string
	Diff **InstanceDiff
}

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

func (*EvalWriteDiff) Eval ΒΆ added in v0.4.0

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

TODO: test

type EvalWriteOutput ΒΆ added in v0.4.0

type EvalWriteOutput struct {
	Name      string
	Sensitive bool
	Value     *config.RawConfig
}

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

func (*EvalWriteOutput) Eval ΒΆ added in v0.4.0

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

TODO: test

type EvalWriteState ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

type EvalWriteStateDeposed ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

type ExpandTransform ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

type FlattenTransformer ΒΆ added in v0.5.0

type FlattenTransformer struct{}

FlattenTransformer is a transformer that goes through the graph, finds subgraphs that can be flattened, and flattens them into this graph, removing the prior subgraph node.

func (*FlattenTransformer) Transform ΒΆ added in v0.5.0

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

type Graph ΒΆ

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. Each graph represents only one module, but it can contain further modules, which themselves have their own graph.

func (*Graph) Add ΒΆ added in v0.4.0

func (g *Graph) Add(v dag.Vertex) dag.Vertex

Add is the same as dag.Graph.Add.

func (*Graph) ConnectDependent ΒΆ added in v0.4.0

func (g *Graph) ConnectDependent(raw dag.Vertex) []string

ConnectDependent connects a GraphNodeDependent to all of its GraphNodeDependables. It returns the list of dependents it was unable to connect to.

func (*Graph) ConnectDependents ΒΆ added in v0.4.0

func (g *Graph) ConnectDependents()

ConnectDependents goes through the graph, connecting all the GraphNodeDependents to GraphNodeDependables. This is safe to call multiple times.

To get details on whether dependencies could be found/made, the more specific ConnectDependent should be used.

func (*Graph) ConnectFrom ΒΆ added in v0.4.0

func (g *Graph) ConnectFrom(source string, target dag.Vertex)

ConnectFrom creates an edge by finding the source from a DependableName and connecting it to the specific vertex.

func (*Graph) ConnectTo ΒΆ added in v0.4.0

func (g *Graph) ConnectTo(v dag.Vertex, targets []string) []string

ConnectTo connects a vertex to a raw string of targets that are the result of DependableName, and returns the list of targets that are missing.

func (*Graph) Dependable ΒΆ added in v0.4.0

func (g *Graph) Dependable(n string) dag.Vertex

Dependable finds the vertices in the graph that have the given dependable names and returns them.

func (*Graph) Remove ΒΆ added in v0.5.0

func (g *Graph) Remove(v dag.Vertex) dag.Vertex

Remove is the same as dag.Graph.Remove

func (*Graph) Replace ΒΆ added in v0.5.0

func (g *Graph) Replace(o, n dag.Vertex) bool

Replace is the same as dag.Graph.Replace

func (*Graph) Walk ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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.

type GraphDotOpts ΒΆ added in v0.3.0

type GraphDotOpts struct {
	// Allows some nodes to decide to only show themselves when the user has
	// requested the "verbose" graph.
	Verbose bool

	// Highlight Cycles
	DrawCycles bool

	// How many levels to expand modules as we draw
	MaxDepth int
}

GraphDotOpts are the options for generating a dot formatted Graph.

type GraphNodeAddressable ΒΆ added in v0.4.0

type GraphNodeAddressable interface {
	ResourceAddress() *ResourceAddress
	// contains filtered or unexported methods
}

GraphNodeAddressable is an interface that all graph nodes for the configuration graph need to implement in order to be be addressed / targeted properly.

type GraphNodeBasicSubgraph ΒΆ added in v0.4.0

type GraphNodeBasicSubgraph struct {
	NameValue string
	Graph     *Graph
}

func (*GraphNodeBasicSubgraph) FlattenGraph ΒΆ added in v0.5.1

func (n *GraphNodeBasicSubgraph) FlattenGraph() *Graph

func (*GraphNodeBasicSubgraph) Name ΒΆ added in v0.4.0

func (n *GraphNodeBasicSubgraph) Name() string

func (*GraphNodeBasicSubgraph) Subgraph ΒΆ added in v0.4.0

func (n *GraphNodeBasicSubgraph) Subgraph() *Graph

type GraphNodeCloseProvider ΒΆ added in v0.6.0

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 ΒΆ added in v0.6.0

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 GraphNodeConfigModule ΒΆ added in v0.4.0

type GraphNodeConfigModule struct {
	Path   []string
	Module *config.Module
	Tree   *module.Tree
}

GraphNodeConfigModule represents a module within the configuration graph.

func (*GraphNodeConfigModule) ConfigType ΒΆ added in v0.4.1

func (*GraphNodeConfigModule) DependableName ΒΆ added in v0.4.0

func (n *GraphNodeConfigModule) DependableName() []string

func (*GraphNodeConfigModule) DependentOn ΒΆ added in v0.4.0

func (n *GraphNodeConfigModule) DependentOn() []string

func (*GraphNodeConfigModule) Expand ΒΆ added in v0.4.0

GraphNodeExpandable

func (*GraphNodeConfigModule) Name ΒΆ added in v0.4.0

func (n *GraphNodeConfigModule) Name() string

func (*GraphNodeConfigModule) ProvidedBy ΒΆ added in v0.4.0

func (n *GraphNodeConfigModule) ProvidedBy() []string

GraphNodeExpandable

type GraphNodeConfigOutput ΒΆ added in v0.4.0

type GraphNodeConfigOutput struct {
	Output *config.Output
}

GraphNodeConfigOutput represents an output configured within the configuration.

func (*GraphNodeConfigOutput) ConfigType ΒΆ added in v0.4.1

func (*GraphNodeConfigOutput) DependableName ΒΆ added in v0.4.0

func (n *GraphNodeConfigOutput) DependableName() []string

func (*GraphNodeConfigOutput) DependentOn ΒΆ added in v0.4.0

func (n *GraphNodeConfigOutput) DependentOn() []string

func (*GraphNodeConfigOutput) DestroyEdgeInclude ΒΆ added in v0.5.0

func (n *GraphNodeConfigOutput) DestroyEdgeInclude(dag.Vertex) bool

GraphNodeDestroyEdgeInclude impl.

func (*GraphNodeConfigOutput) EvalTree ΒΆ added in v0.4.0

func (n *GraphNodeConfigOutput) EvalTree() EvalNode

GraphNodeEvalable impl.

func (*GraphNodeConfigOutput) Flatten ΒΆ added in v0.5.0

func (n *GraphNodeConfigOutput) Flatten(p []string) (dag.Vertex, error)

GraphNodeFlattenable impl.

func (*GraphNodeConfigOutput) Name ΒΆ added in v0.4.0

func (n *GraphNodeConfigOutput) Name() string

func (*GraphNodeConfigOutput) OutputName ΒΆ added in v0.5.0

func (n *GraphNodeConfigOutput) OutputName() string

func (*GraphNodeConfigOutput) Proxy ΒΆ added in v0.5.0

func (n *GraphNodeConfigOutput) Proxy() bool

GraphNodeProxy impl.

type GraphNodeConfigOutputFlat ΒΆ added in v0.5.0

type GraphNodeConfigOutputFlat struct {
	*GraphNodeConfigOutput

	PathValue []string
}

Same as GraphNodeConfigOutput, but for flattening

func (*GraphNodeConfigOutputFlat) DependableName ΒΆ added in v0.5.0

func (n *GraphNodeConfigOutputFlat) DependableName() []string

func (*GraphNodeConfigOutputFlat) DependentOn ΒΆ added in v0.5.0

func (n *GraphNodeConfigOutputFlat) DependentOn() []string

func (*GraphNodeConfigOutputFlat) Name ΒΆ added in v0.5.0

func (*GraphNodeConfigOutputFlat) Path ΒΆ added in v0.5.0

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

type GraphNodeConfigProvider ΒΆ added in v0.4.0

type GraphNodeConfigProvider struct {
	Provider *config.ProviderConfig
}

GraphNodeConfigProvider represents a configured provider within the configuration graph. These are only immediately in the graph when an explicit `provider` configuration block is in the configuration.

func (*GraphNodeConfigProvider) ConfigType ΒΆ added in v0.4.1

func (*GraphNodeConfigProvider) DependableName ΒΆ added in v0.4.0

func (n *GraphNodeConfigProvider) DependableName() []string

func (*GraphNodeConfigProvider) DependentOn ΒΆ added in v0.4.0

func (n *GraphNodeConfigProvider) DependentOn() []string

func (*GraphNodeConfigProvider) DotNode ΒΆ added in v0.5.0

func (n *GraphNodeConfigProvider) DotNode(name string, opts *GraphDotOpts) *dot.Node

GraphNodeDotter impl.

func (*GraphNodeConfigProvider) DotOrigin ΒΆ added in v0.5.0

func (n *GraphNodeConfigProvider) DotOrigin() bool

GraphNodeDotterOrigin impl.

func (*GraphNodeConfigProvider) EvalTree ΒΆ added in v0.4.0

func (n *GraphNodeConfigProvider) EvalTree() EvalNode

GraphNodeEvalable impl.

func (*GraphNodeConfigProvider) Flatten ΒΆ added in v0.5.0

func (n *GraphNodeConfigProvider) Flatten(p []string) (dag.Vertex, error)

GraphNodeFlattenable impl.

func (*GraphNodeConfigProvider) Name ΒΆ added in v0.4.0

func (n *GraphNodeConfigProvider) Name() string

func (*GraphNodeConfigProvider) ProviderConfig ΒΆ added in v0.4.1

func (n *GraphNodeConfigProvider) ProviderConfig() *config.RawConfig

GraphNodeProvider implementation

func (*GraphNodeConfigProvider) ProviderName ΒΆ added in v0.4.0

func (n *GraphNodeConfigProvider) ProviderName() string

GraphNodeProvider implementation

type GraphNodeConfigProviderFlat ΒΆ added in v0.5.0

type GraphNodeConfigProviderFlat struct {
	*GraphNodeConfigProvider

	PathValue []string
}

Same as GraphNodeConfigProvider, but for flattening

func (*GraphNodeConfigProviderFlat) DependableName ΒΆ added in v0.5.0

func (n *GraphNodeConfigProviderFlat) DependableName() []string

func (*GraphNodeConfigProviderFlat) DependentOn ΒΆ added in v0.5.0

func (n *GraphNodeConfigProviderFlat) DependentOn() []string

func (*GraphNodeConfigProviderFlat) Name ΒΆ added in v0.5.0

func (*GraphNodeConfigProviderFlat) Path ΒΆ added in v0.5.0

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

func (*GraphNodeConfigProviderFlat) ProviderName ΒΆ added in v0.5.0

func (n *GraphNodeConfigProviderFlat) ProviderName() string

type GraphNodeConfigResource ΒΆ added in v0.4.0

type GraphNodeConfigResource struct {
	Resource *config.Resource

	// If set to true, this resource represents a resource
	// that will be destroyed in some way.
	Destroy bool

	// Used during DynamicExpand to target indexes
	Targets []ResourceAddress

	Path []string
}

GraphNodeConfigResource represents a resource within the config graph.

func (*GraphNodeConfigResource) ConfigType ΒΆ added in v0.4.1

func (*GraphNodeConfigResource) Copy ΒΆ added in v0.6.12

func (*GraphNodeConfigResource) CountDependentOn ΒΆ added in v0.5.0

func (n *GraphNodeConfigResource) CountDependentOn() []string

GraphNodeCountDependent impl.

func (*GraphNodeConfigResource) DependableName ΒΆ added in v0.4.0

func (n *GraphNodeConfigResource) DependableName() []string

func (*GraphNodeConfigResource) DependentOn ΒΆ added in v0.4.0

func (n *GraphNodeConfigResource) DependentOn() []string

GraphNodeDependent impl.

func (*GraphNodeConfigResource) DestroyNode ΒΆ added in v0.4.0

func (n *GraphNodeConfigResource) DestroyNode() GraphNodeDestroy

GraphNodeDestroyable

func (*GraphNodeConfigResource) DotNode ΒΆ added in v0.5.0

func (n *GraphNodeConfigResource) DotNode(name string, opts *GraphDotOpts) *dot.Node

GraphNodeDotter impl.

func (*GraphNodeConfigResource) DynamicExpand ΒΆ added in v0.4.0

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

GraphNodeDynamicExpandable impl.

func (*GraphNodeConfigResource) EvalTree ΒΆ added in v0.4.0

func (n *GraphNodeConfigResource) EvalTree() EvalNode

GraphNodeEvalable impl.

func (*GraphNodeConfigResource) Flatten ΒΆ added in v0.5.0

func (n *GraphNodeConfigResource) Flatten(p []string) (dag.Vertex, error)

GraphNodeFlattenable impl.

func (*GraphNodeConfigResource) Name ΒΆ added in v0.4.0

func (n *GraphNodeConfigResource) Name() string

func (*GraphNodeConfigResource) Noop ΒΆ added in v0.6.1

func (n *GraphNodeConfigResource) Noop(opts *NoopOpts) bool

GraphNodeNoopPrunable

func (*GraphNodeConfigResource) ProvidedBy ΒΆ added in v0.4.0

func (n *GraphNodeConfigResource) ProvidedBy() []string

GraphNodeProviderConsumer

func (*GraphNodeConfigResource) ProvisionedBy ΒΆ added in v0.4.0

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

GraphNodeProvisionerConsumer

func (*GraphNodeConfigResource) ResourceAddress ΒΆ added in v0.4.0

func (n *GraphNodeConfigResource) ResourceAddress() *ResourceAddress

GraphNodeAddressable impl.

func (*GraphNodeConfigResource) SetTargets ΒΆ added in v0.4.0

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

GraphNodeTargetable impl.

func (*GraphNodeConfigResource) VarWalk ΒΆ added in v0.5.0

VarWalk calls a callback for all the variables that this resource depends on.

type GraphNodeConfigResourceFlat ΒΆ added in v0.5.0

type GraphNodeConfigResourceFlat struct {
	*GraphNodeConfigResource

	PathValue []string
}

Same as GraphNodeConfigResource, but for flattening

func (*GraphNodeConfigResourceFlat) DependableName ΒΆ added in v0.5.0

func (n *GraphNodeConfigResourceFlat) DependableName() []string

func (*GraphNodeConfigResourceFlat) DependentOn ΒΆ added in v0.5.0

func (n *GraphNodeConfigResourceFlat) DependentOn() []string

func (*GraphNodeConfigResourceFlat) DestroyNode ΒΆ added in v0.5.0

GraphNodeDestroyable impl.

func (*GraphNodeConfigResourceFlat) Name ΒΆ added in v0.5.0

func (*GraphNodeConfigResourceFlat) Path ΒΆ added in v0.5.0

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

func (*GraphNodeConfigResourceFlat) ProvidedBy ΒΆ added in v0.5.0

func (n *GraphNodeConfigResourceFlat) ProvidedBy() []string

func (*GraphNodeConfigResourceFlat) ProvisionedBy ΒΆ added in v0.5.0

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

type GraphNodeConfigType ΒΆ added in v0.4.1

type GraphNodeConfigType int

GraphNodeConfigType is an enum for the type of thing that a graph node represents from the configuration.

const (
	GraphNodeConfigTypeInvalid  GraphNodeConfigType = 0
	GraphNodeConfigTypeResource GraphNodeConfigType = iota
	GraphNodeConfigTypeProvider
	GraphNodeConfigTypeModule
	GraphNodeConfigTypeOutput
	GraphNodeConfigTypeVariable
)

func (GraphNodeConfigType) String ΒΆ added in v0.4.1

func (i GraphNodeConfigType) String() string

type GraphNodeConfigVariable ΒΆ added in v0.5.0

type GraphNodeConfigVariable struct {
	Variable *config.Variable

	// Value, if non-nil, will be used to set the value of the variable
	// during evaluation. If this is nil, evaluation will do nothing.
	//
	// Module is the name of the module to set the variables on.
	Module string
	Value  *config.RawConfig

	ModuleTree *module.Tree
	ModulePath []string
}

GraphNodeConfigVariable represents a Variable in the config.

func (*GraphNodeConfigVariable) ConfigType ΒΆ added in v0.5.0

func (*GraphNodeConfigVariable) DependableName ΒΆ added in v0.5.0

func (n *GraphNodeConfigVariable) DependableName() []string

func (*GraphNodeConfigVariable) DependentOn ΒΆ added in v0.5.0

func (n *GraphNodeConfigVariable) DependentOn() []string

func (*GraphNodeConfigVariable) DestroyEdgeInclude ΒΆ added in v0.5.0

func (n *GraphNodeConfigVariable) DestroyEdgeInclude(v dag.Vertex) bool

GraphNodeDestroyEdgeInclude impl.

func (*GraphNodeConfigVariable) EvalTree ΒΆ added in v0.5.0

func (n *GraphNodeConfigVariable) EvalTree() EvalNode

GraphNodeEvalable impl.

func (*GraphNodeConfigVariable) Flatten ΒΆ added in v0.5.0

func (n *GraphNodeConfigVariable) Flatten(p []string) (dag.Vertex, error)

GraphNodeFlattenable impl.

func (*GraphNodeConfigVariable) Name ΒΆ added in v0.5.0

func (n *GraphNodeConfigVariable) Name() string

func (*GraphNodeConfigVariable) Noop ΒΆ added in v0.6.1

func (n *GraphNodeConfigVariable) Noop(opts *NoopOpts) bool

GraphNodeNoopPrunable

func (*GraphNodeConfigVariable) Proxy ΒΆ added in v0.5.0

func (n *GraphNodeConfigVariable) Proxy() bool

GraphNodeProxy impl.

func (*GraphNodeConfigVariable) VariableName ΒΆ added in v0.5.0

func (n *GraphNodeConfigVariable) VariableName() string

type GraphNodeConfigVariableFlat ΒΆ added in v0.5.0

type GraphNodeConfigVariableFlat struct {
	*GraphNodeConfigVariable

	PathValue []string
}

func (*GraphNodeConfigVariableFlat) DependableName ΒΆ added in v0.5.0

func (n *GraphNodeConfigVariableFlat) DependableName() []string

func (*GraphNodeConfigVariableFlat) DependentOn ΒΆ added in v0.5.0

func (n *GraphNodeConfigVariableFlat) DependentOn() []string

func (*GraphNodeConfigVariableFlat) Name ΒΆ added in v0.5.0

func (*GraphNodeConfigVariableFlat) Path ΒΆ added in v0.5.0

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

type GraphNodeCountDependent ΒΆ added in v0.5.0

type GraphNodeCountDependent interface {
	CountDependentOn() []string
}

GraphNodeCountDependent is implemented by resources for giving only the dependencies they have from the "count" field.

type GraphNodeDependable ΒΆ added in v0.4.0

type GraphNodeDependable interface {
	DependableName() []string
}

GraphNodeDependable is an interface which says that a node can be depended on (an edge can be placed between this node and another) according to the well-known name returned by DependableName.

DependableName can return multiple names it is known by.

type GraphNodeDependent ΒΆ added in v0.4.0

type GraphNodeDependent interface {
	DependentOn() []string
}

GraphNodeDependent is an interface which says that a node depends on another GraphNodeDependable by some name. By implementing this interface, Graph.ConnectDependents() can be called multiple times safely and efficiently.

type GraphNodeDestroy ΒΆ added in v0.4.0

type GraphNodeDestroy interface {
	dag.Vertex

	// CreateBeforeDestroy is called to check whether this node
	// should be created before it is destroyed. The CreateBeforeDestroy
	// transformer uses this information to setup the graph.
	CreateBeforeDestroy() bool

	// CreateNode returns the node used for the create side of this
	// destroy. This must already exist within the graph.
	CreateNode() dag.Vertex
}

GraphNodeDestroy is the interface that must implemented by nodes that destroy.

type GraphNodeDestroyEdgeInclude ΒΆ added in v0.5.0

type GraphNodeDestroyEdgeInclude interface {
	DestroyEdgeInclude(dag.Vertex) bool
}

GraphNodeEdgeInclude can be implemented to not include something as an edge within the destroy graph. This is usually done because it might cause unnecessary cycles.

type GraphNodeDestroyPrunable ΒΆ added in v0.4.0

type GraphNodeDestroyPrunable interface {
	// DestroyInclude is called to check if this node should be included
	// with the given state. The state and diff must NOT be modified.
	DestroyInclude(*ModuleDiff, *ModuleState) bool
}

GraphNodeDestroyPrunable is the interface that can be implemented to signal that this node can be pruned depending on state.

type GraphNodeDestroyable ΒΆ added in v0.4.0

type GraphNodeDestroyable interface {
	// DestroyNode returns the node used for the destroy with the given
	// mode. If this returns nil, then a destroy node for that mode
	// will not be added.
	DestroyNode() GraphNodeDestroy
}

GraphNodeDestroyable is the interface that nodes that can be destroyed must implement. This is used to automatically handle the creation of destroy nodes in the graph and the dependency ordering of those destroys.

type GraphNodeDotOrigin ΒΆ added in v0.5.0

type GraphNodeDotOrigin interface {
	DotOrigin() bool
}

type GraphNodeDotter ΒΆ added in v0.4.0

type GraphNodeDotter interface {
	// Dot is called to return the dot formatting for the node.
	// The first parameter is the title of the node.
	// The second parameter includes user-specified options that affect the dot
	// graph. See GraphDotOpts below for details.
	DotNode(string, *GraphDotOpts) *dot.Node
}

GraphNodeDotter can be implemented by a node to cause it to be included in the dot graph. The Dot method will be called which is expected to return a representation of this node.

type GraphNodeDynamicExpandable ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

type GraphNodeEvalable interface {
	EvalTree() EvalNode
}

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

type GraphNodeExpandable ΒΆ added in v0.4.0

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 GraphNodeFlatGraph ΒΆ added in v0.5.0

type GraphNodeFlatGraph interface {
	FlattenGraph() *Graph
}

GraphNodeFlatGraph must be implemented by nodes that have subgraphs that they want flattened into the graph.

type GraphNodeFlattenable ΒΆ added in v0.5.0

type GraphNodeFlattenable interface {
	Flatten(path []string) (dag.Vertex, error)
}

GraphNodeFlattenable must be implemented by all nodes that can be flattened. If a FlattenGraph returns any nodes that can't be flattened, it will be an error.

If Flatten returns nil for the Vertex along with a nil error, it will removed from the graph.

type GraphNodeNoopPrunable ΒΆ added in v0.6.1

type GraphNodeNoopPrunable interface {
	Noop(*NoopOpts) bool
}

GraphNodeNoopPrunable can be implemented by nodes that can be pruned if they are noops.

type GraphNodeOutput ΒΆ added in v0.5.0

type GraphNodeOutput interface {
	OutputName() string
}

GraphNodeOutput is an interface that nodes that are outputs must implement. The OutputName returned is the name of the output key that they manage.

type GraphNodeProvider ΒΆ added in v0.4.0

type GraphNodeProvider interface {
	ProviderName() string
	ProviderConfig() *config.RawConfig
}

GraphNodeProvider is an interface that nodes that can be a provider must implement. The ProviderName returned is the name of the provider they satisfy.

type GraphNodeProviderConsumer ΒΆ added in v0.4.0

type GraphNodeProviderConsumer interface {
	ProvidedBy() []string
}

GraphNodeProviderConsumer is an interface that nodes that require a provider must implement. ProvidedBy must return the name of the provider to use.

type GraphNodeProvisioner ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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 GraphNodeProxy ΒΆ added in v0.5.0

type GraphNodeProxy interface {
	Proxy() bool
}

GraphNodeProxy must be implemented by nodes that are proxies.

A node that is a proxy says that anything that depends on this node (the proxy), should also copy all the things that the proxy itself depends on. Example:

A => proxy => C

Should transform into (two edges):

A => proxy => C
A => C

The purpose for this is because some transforms only look at direct edge connections and the proxy generally isn't meaningful in those situations, so we should complete all the edges.

type GraphNodeStateRepresentative ΒΆ added in v0.4.0

type GraphNodeStateRepresentative interface {
	StateId() []string
}

GraphNodeStateRepresentative is an interface that can be implemented by a node to say that it is representing a resource in the state.

type GraphNodeSubPath ΒΆ added in v0.5.0

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 ΒΆ added in v0.4.0

type GraphNodeSubgraph interface {
	Subgraph() *Graph
}

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

type GraphNodeTargetable ΒΆ added in v0.4.0

type GraphNodeTargetable interface {
	GraphNodeAddressable

	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 GraphProxyEdge ΒΆ added in v0.5.0

type GraphProxyEdge struct {
	dag.Edge
}

GraphProxyEdge is the edge that is used for proxied edges.

type GraphSemanticChecker ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

type GraphTransformer interface {
	Transform(*Graph) error
}

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

type GraphVertexTransformer ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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 Hook ΒΆ

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) (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 ΒΆ

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 ΒΆ

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 ΒΆ

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

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

func (*ImportGraphBuilder) Steps ΒΆ

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

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

type ImportOpts ΒΆ

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 ImportStateTransformer ΒΆ

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 ΒΆ

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

type ImportTarget ΒΆ

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
}

ImportTarget is a single resource to import.

type InputMode ΒΆ added in v0.3.0

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
	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 ΒΆ added in v0.3.0

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 ΒΆ added in v0.3.0

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

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

func (*InstanceDiff) ChangeType ΒΆ added in v0.3.0

func (d *InstanceDiff) ChangeType() DiffChangeType

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

func (*InstanceDiff) Empty ΒΆ added in v0.3.0

func (d *InstanceDiff) Empty() bool

Empty returns true if this diff encapsulates no changes.

func (*InstanceDiff) GoString ΒΆ added in v0.4.0

func (d *InstanceDiff) GoString() string

func (*InstanceDiff) RequiresNew ΒΆ added in v0.3.0

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 ΒΆ added in v0.3.0

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.

type InstanceInfo ΒΆ added in v0.3.0

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
}

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

func (*InstanceInfo) HumanId ΒΆ added in v0.3.0

func (i *InstanceInfo) HumanId() string

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

type InstanceState ΒΆ added in v0.3.0

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,omitempty"`

	// 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.
	Meta map[string]string `json:"meta,omitempty"`

	// Tainted is used to mark a resource for recreation.
	Tainted bool `json:"tainted,omitempty"`
}

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

func (*InstanceState) DeepCopy ΒΆ

func (i *InstanceState) DeepCopy() *InstanceState

func (*InstanceState) Empty ΒΆ added in v0.4.0

func (s *InstanceState) Empty() bool

func (*InstanceState) Equal ΒΆ added in v0.4.0

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

func (*InstanceState) GoString ΒΆ added in v0.3.0

func (i *InstanceState) GoString() string

func (*InstanceState) MergeDiff ΒΆ added in v0.3.0

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) String ΒΆ added in v0.3.0

func (i *InstanceState) String() string

type InstanceType ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

func ParseInstanceType(s string) (InstanceType, error)

func (InstanceType) String ΒΆ added in v0.4.0

func (i InstanceType) String() string

type Interpolater ΒΆ added in v0.4.0

type Interpolater struct {
	Operation          walkOperation
	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 ΒΆ added in v0.4.0

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

type InterpolationScope ΒΆ added in v0.4.0

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 MissingProviderTransformer ΒΆ added in v0.4.0

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

MissingProviderTransformer is a GraphTransformer that adds nodes for missing 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 ΒΆ added in v0.4.0

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

type MissingProvisionerTransformer ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

type MockEvalContext ΒΆ added in v0.4.0

type MockEvalContext 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

	SetProviderConfigCalled bool
	SetProviderConfigName   string
	SetProviderConfigConfig *ResourceConfig

	ParentProviderConfigCalled bool
	ParentProviderConfigName   string
	ParentProviderConfigConfig *ResourceConfig

	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

	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 ΒΆ added in v0.6.0

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

func (*MockEvalContext) CloseProvisioner ΒΆ added in v0.6.0

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

func (*MockEvalContext) ConfigureProvider ΒΆ added in v0.4.0

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

func (*MockEvalContext) Diff ΒΆ added in v0.4.0

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

func (*MockEvalContext) Hook ΒΆ added in v0.4.0

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

func (*MockEvalContext) InitProvider ΒΆ added in v0.4.0

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

func (*MockEvalContext) InitProvisioner ΒΆ added in v0.4.0

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

func (*MockEvalContext) Input ΒΆ added in v0.4.0

func (c *MockEvalContext) Input() UIInput

func (*MockEvalContext) Interpolate ΒΆ added in v0.4.0

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

func (*MockEvalContext) ParentProviderConfig ΒΆ added in v0.4.0

func (c *MockEvalContext) ParentProviderConfig(n string) *ResourceConfig

func (*MockEvalContext) Path ΒΆ added in v0.4.0

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

func (*MockEvalContext) Provider ΒΆ added in v0.4.0

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

func (*MockEvalContext) ProviderInput ΒΆ added in v0.4.0

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

func (*MockEvalContext) Provisioner ΒΆ added in v0.4.0

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

func (*MockEvalContext) SetProviderConfig ΒΆ added in v0.4.1

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

func (*MockEvalContext) SetProviderInput ΒΆ added in v0.4.0

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

func (*MockEvalContext) SetVariables ΒΆ added in v0.4.0

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

func (*MockEvalContext) State ΒΆ added in v0.4.0

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

type MockHook ΒΆ

type MockHook struct {
	PreApplyCalled bool
	PreApplyInfo   *InstanceInfo
	PreApplyDiff   *InstanceDiff
	PreApplyState  *InstanceState
	PreApplyReturn HookAction
	PreApplyError  error

	PostApplyCalled      bool
	PostApplyInfo        *InstanceInfo
	PostApplyState       *InstanceState
	PostApplyError       error
	PostApplyReturn      HookAction
	PostApplyReturnError 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
	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 ΒΆ

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

func (*MockHook) PostDiff ΒΆ

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

func (*MockHook) PostImportState ΒΆ

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

func (*MockHook) PostProvision ΒΆ

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

func (*MockHook) PostProvisionResource ΒΆ

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

func (*MockHook) PostRefresh ΒΆ

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

func (*MockHook) PostStateUpdate ΒΆ added in v0.4.0

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

func (*MockHook) PreApply ΒΆ

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

func (*MockHook) PreDiff ΒΆ

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

func (*MockHook) PreImportState ΒΆ

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

func (*MockHook) PreProvision ΒΆ

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

func (*MockHook) PreProvisionResource ΒΆ

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

func (*MockHook) PreRefresh ΒΆ

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

func (*MockHook) ProvisionOutput ΒΆ added in v0.3.0

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

type MockResourceProvider ΒΆ

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
	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
	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 ΒΆ

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

func (*MockResourceProvider) Close ΒΆ added in v0.6.0

func (p *MockResourceProvider) Close() error

func (*MockResourceProvider) Configure ΒΆ

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

func (*MockResourceProvider) DataSources ΒΆ

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

func (*MockResourceProvider) Diff ΒΆ

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

func (*MockResourceProvider) ImportState ΒΆ

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

func (*MockResourceProvider) Input ΒΆ added in v0.3.0

func (*MockResourceProvider) ReadDataApply ΒΆ

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

func (*MockResourceProvider) ReadDataDiff ΒΆ

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

func (*MockResourceProvider) Refresh ΒΆ

func (*MockResourceProvider) Resources ΒΆ

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

func (*MockResourceProvider) Validate ΒΆ

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

func (*MockResourceProvider) ValidateDataSource ΒΆ

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

func (*MockResourceProvider) ValidateResource ΒΆ

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

type MockResourceProvisioner ΒΆ

type MockResourceProvisioner struct {
	// 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
}

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

func (*MockResourceProvisioner) Apply ΒΆ

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

func (*MockResourceProvisioner) Validate ΒΆ

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

type MockUIInput ΒΆ added in v0.3.0

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 ΒΆ added in v0.3.0

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

type MockUIOutput ΒΆ added in v0.3.0

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

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

func (*MockUIOutput) Output ΒΆ added in v0.3.0

func (o *MockUIOutput) Output(v string)

type ModuleDestroyTransformer ΒΆ added in v0.5.0

type ModuleDestroyTransformer struct{}

ModuleDestroyTransformer is a GraphTransformer that adds a node to the graph that will just mark the full module for destroy in the destroy scenario.

func (*ModuleDestroyTransformer) Transform ΒΆ added in v0.5.0

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

type ModuleDiff ΒΆ added in v0.3.0

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 ΒΆ added in v0.3.0

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 ΒΆ added in v0.3.0

func (d *ModuleDiff) Empty() bool

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

func (*ModuleDiff) Instances ΒΆ added in v0.3.0

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 ΒΆ added in v0.3.0

func (d *ModuleDiff) IsRoot() bool

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

func (*ModuleDiff) String ΒΆ added in v0.3.0

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 ΒΆ added in v0.3.0

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"`

	// 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,omitempty"`
}

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) Equal ΒΆ added in v0.4.0

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

Equal tests whether one module state is equal to another.

func (*ModuleState) GoString ΒΆ added in v0.3.0

func (m *ModuleState) GoString() string

func (*ModuleState) IsRoot ΒΆ added in v0.3.0

func (m *ModuleState) IsRoot() bool

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

func (*ModuleState) Orphans ΒΆ added in v0.3.0

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) String ΒΆ added in v0.3.0

func (m *ModuleState) String() string

func (*ModuleState) View ΒΆ added in v0.3.0

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

View returns a view with the given resource prefix.

type NilHook ΒΆ

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 ΒΆ

func (*NilHook) PostDiff ΒΆ

func (*NilHook) PostImportState ΒΆ

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

func (*NilHook) PostProvision ΒΆ

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

func (*NilHook) PostProvisionResource ΒΆ

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

func (*NilHook) PostRefresh ΒΆ

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

func (*NilHook) PostStateUpdate ΒΆ added in v0.4.0

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

func (*NilHook) PreApply ΒΆ

func (*NilHook) PreDiff ΒΆ

func (*NilHook) PreImportState ΒΆ

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

func (*NilHook) PreProvision ΒΆ

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

func (*NilHook) PreProvisionResource ΒΆ

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

func (*NilHook) PreRefresh ΒΆ

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

func (*NilHook) ProvisionOutput ΒΆ added in v0.3.0

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

type NoopOpts ΒΆ added in v0.6.1

type NoopOpts struct {
	Graph    *Graph
	Vertex   dag.Vertex
	Diff     *Diff
	State    *State
	ModDiff  *ModuleDiff
	ModState *ModuleState
}

NoopOpts are the options available to determine if your node is a noop.

type NullGraphWalker ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

func (NullGraphWalker) EnterPath ΒΆ added in v0.5.0

func (NullGraphWalker) EnterPath([]string) EvalContext

func (NullGraphWalker) EnterVertex ΒΆ added in v0.4.0

func (NullGraphWalker) EnterVertex(dag.Vertex)

func (NullGraphWalker) ExitEvalTree ΒΆ added in v0.4.0

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

func (NullGraphWalker) ExitPath ΒΆ added in v0.5.0

func (NullGraphWalker) ExitPath([]string)

func (NullGraphWalker) ExitVertex ΒΆ added in v0.4.0

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

type OrphanTransformer ΒΆ added in v0.4.0

type OrphanTransformer struct {
	// 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

	// View, if non-nil will set a view on the module state.
	View string
}

OrphanTransformer is a GraphTransformer that adds orphans to the graph. This transformer adds both resource and module orphans.

func (*OrphanTransformer) Transform ΒΆ added in v0.4.0

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

type OutputState ΒΆ

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"`
}

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

func (*OutputState) Equal ΒΆ

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

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

func (*OutputState) String ΒΆ

func (s *OutputState) String() string

type Plan ΒΆ

type Plan struct {
	Diff    *Diff
	Module  *module.Tree
	State   *State
	Vars    map[string]string
	Targets []string
	// contains filtered or unexported fields
}

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

func ReadPlan ΒΆ

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 ΒΆ

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, State, Variables.

func (*Plan) String ΒΆ

func (p *Plan) String() string

type PrefixUIInput ΒΆ added in v0.3.0

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 ΒΆ added in v0.3.0

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

type ProviderTransformer ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

type ProvisionerTransformer ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

type ProvisionerUIOutput ΒΆ added in v0.3.0

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 ΒΆ added in v0.3.0

func (o *ProvisionerUIOutput) Output(msg string)

type ProxyTransformer ΒΆ added in v0.5.0

type ProxyTransformer struct{}

ProxyTransformer is a transformer that goes through the graph, finds vertices that are marked as proxies, and connects through their dependents. See above for what a proxy is.

func (*ProxyTransformer) Transform ΒΆ added in v0.5.0

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

type PruneDestroyTransformer ΒΆ added in v0.4.0

type PruneDestroyTransformer struct {
	Diff  *Diff
	State *State
}

PruneDestroyTransformer is a GraphTransformer that removes the destroy nodes that aren't in the diff.

func (*PruneDestroyTransformer) Transform ΒΆ added in v0.4.0

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

type PruneNoopTransformer ΒΆ added in v0.6.1

type PruneNoopTransformer struct {
	Diff  *Diff
	State *State
}

PruneNoopTransformer is a graph transform that prunes nodes that consider themselves no-ops. This is done to both simplify the graph as well as to remove graph nodes that might otherwise cause problems during the graph run. Therefore, this transformer isn't completely an optimization step, and can instead be considered critical to Terraform operations.

Example of the above case: variables for modules interpolate their values. Interpolation will fail on destruction (since attributes are being deleted), but variables shouldn't even eval if there is nothing that will consume the variable. Therefore, variables can note that they can be omitted safely in this case.

The PruneNoopTransformer will prune nodes depth first, and will automatically create connect through the dependencies of pruned nodes. For example, if we have a graph A => B => C (A depends on B, etc.), and B decides to be removed, we'll still be left with A => C; the edge will be properly connected.

func (*PruneNoopTransformer) Transform ΒΆ added in v0.6.1

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

type PruneProviderTransformer ΒΆ added in v0.4.0

type PruneProviderTransformer struct{}

PruneProviderTransformer is a GraphTransformer that prunes all the providers that aren't needed from the graph. A provider is unneeded if no resource or module is using that provider.

func (*PruneProviderTransformer) Transform ΒΆ added in v0.4.0

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

type RemoteState ΒΆ added in v0.3.5

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"`
}

RemoteState is used to track the information about a remote state store that we push/pull state to.

func (*RemoteState) Empty ΒΆ added in v0.3.5

func (r *RemoteState) Empty() bool

func (*RemoteState) Equals ΒΆ added in v0.3.5

func (r *RemoteState) Equals(other *RemoteState) bool

func (*RemoteState) GoString ΒΆ added in v0.4.0

func (r *RemoteState) GoString() string

type Resource ΒΆ

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 ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

func ParseResourceAddress(s string) (*ResourceAddress, error)

func (*ResourceAddress) Copy ΒΆ added in v0.6.12

func (r *ResourceAddress) Copy() *ResourceAddress

Copy returns a copy of this ResourceAddress

func (*ResourceAddress) Equals ΒΆ added in v0.4.0

func (addr *ResourceAddress) Equals(raw interface{}) bool

func (*ResourceAddress) String ΒΆ

func (r *ResourceAddress) String() string

String outputs the address that parses into this address.

type ResourceAttrDiff ΒΆ

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 ΒΆ added in v0.6.14

func (d *ResourceAttrDiff) Empty() bool

Empty returns true if the diff for this attr is neutral

func (*ResourceAttrDiff) GoString ΒΆ

func (d *ResourceAttrDiff) GoString() string

type ResourceConfig ΒΆ

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 ΒΆ

func NewResourceConfig(c *config.RawConfig) *ResourceConfig

NewResourceConfig creates a new ResourceConfig from a config.RawConfig.

func (*ResourceConfig) CheckSet ΒΆ

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) Get ΒΆ

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 not succeed if the value is being computed.

func (*ResourceConfig) GetRaw ΒΆ added in v0.5.0

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 ΒΆ added in v0.3.0

func (c *ResourceConfig) IsComputed(k string) bool

IsComputed returns whether the given key is computed or not.

func (*ResourceConfig) IsSet ΒΆ

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 ΒΆ added in v0.4.0

type ResourceCountTransformer struct {
	Resource *config.Resource
	Destroy  bool
	Targets  []ResourceAddress
}

ResourceCountTransformer is a GraphTransformer that expands the count out for a specific resource.

func (*ResourceCountTransformer) Transform ΒΆ added in v0.4.0

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

type ResourceDependency ΒΆ

type ResourceDependency struct {
	// ID of the resource that we depend on. This ID should map
	// directly to another ResourceState's ID.
	ID string
}

ResourceDependency maps a resource to another resource that it depends on to remain intact and uncorrupted.

type ResourceFlag ΒΆ added in v0.3.0

type ResourceFlag byte

ResourceKind specifies what kind of instance we're working with, whether its a primary instance, a tainted instance, or an orphan.

const (
	FlagPrimary ResourceFlag = 1 << iota
	FlagTainted
	FlagOrphan
	FlagReplacePrimary
	FlagDeposed
)

type ResourceProvider ΒΆ

type ResourceProvider interface {

	// 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

	// 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.

type ResourceProviderCloser ΒΆ added in v0.6.0

type ResourceProviderCloser interface {
	Close() error
}

ResourceProviderCloser is an interface that providers that can close connections that aren't needed anymore must implement.

type ResourceProviderFactory ΒΆ

type ResourceProviderFactory func() (ResourceProvider, error)

ResourceProviderFactory is a function type that creates a new instance of a resource provider.

func ResourceProviderFactoryFixed ΒΆ

func ResourceProviderFactoryFixed(p ResourceProvider) ResourceProviderFactory

ResourceProviderFactoryFixed is a helper that creates a ResourceProviderFactory that just returns some fixed provider.

type ResourceProvisioner ΒΆ

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
}

ResourceProvisioner is an interface that must be implemented by any resource provisioner: the thing that initializes resources in a Terraform configuration.

type ResourceProvisionerCloser ΒΆ added in v0.6.0

type ResourceProvisionerCloser interface {
	Close() error
}

ResourceProvisionerCloser is an interface that provisioners that can close connections that aren't needed anymore must implement.

type ResourceProvisionerConfig ΒΆ

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 ΒΆ

type ResourceProvisionerFactory func() (ResourceProvisioner, error)

ResourceProvisionerFactory is a function type that creates a new instance of a resource provisioner.

type ResourceState ΒΆ

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,omitempty"`

	// 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,omitempty"`

	// 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,omitempty"`
}

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 ΒΆ added in v0.4.0

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

Equal tests whether two ResourceStates are equal.

func (*ResourceState) GoString ΒΆ added in v0.2.0

func (s *ResourceState) GoString() string

func (*ResourceState) String ΒΆ added in v0.3.0

func (s *ResourceState) String() string

func (*ResourceState) Taint ΒΆ added in v0.4.0

func (r *ResourceState) Taint()

Taint marks a resource as tainted.

func (*ResourceState) Untaint ΒΆ added in v0.6.13

func (r *ResourceState) Untaint()

Untaint unmarks a resource as tainted.

type ResourceStateKey ΒΆ added in v0.6.10

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 ΒΆ added in v0.6.10

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 ΒΆ added in v0.6.10

func (rsk *ResourceStateKey) Equal(other *ResourceStateKey) bool

Equal determines whether two ResourceStateKeys are the same

func (*ResourceStateKey) String ΒΆ added in v0.6.10

func (rsk *ResourceStateKey) String() string

type ResourceStateV0 ΒΆ

type ResourceStateV0 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

	// A unique ID for this resource. This is opaque to Terraform
	// and is only meant as a lookup mechanism for the providers.
	ID string

	// 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

	// 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

	// Extra information that the provider can store about a resource.
	// This data is opaque, never shown to the user, and is sent back to
	// the provider as-is for whatever purpose appropriate.
	Extra map[string]interface{}

	// 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 []ResourceDependency
}

/ 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 uesd 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 (*ResourceStateV0) GoString ΒΆ

func (s *ResourceStateV0) GoString() string

func (*ResourceStateV0) MergeDiff ΒΆ

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

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.

type ResourceType ΒΆ

type ResourceType struct {
	Name       string // Name of the resource, example "instance" (no provider prefix)
	Importable bool   // Whether this resource supports importing
}

ResourceType is a type of resource that a resource provider can manage.

type RootTransformer ΒΆ added in v0.4.0

type RootTransformer struct{}

RootTransformer is a GraphTransformer that adds a root to the graph.

func (*RootTransformer) Transform ΒΆ added in v0.4.0

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

type SemanticCheckModulesExist ΒΆ added in v0.4.0

type SemanticCheckModulesExist struct{}

SemanticCheckModulesExist is an implementation of SemanticChecker that verifies that all the modules that are referenced in the graph exist.

func (*SemanticCheckModulesExist) Check ΒΆ added in v0.4.0

TODO: test

type SemanticChecker ΒΆ added in v0.4.0

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 ΒΆ added in v0.3.1

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 ΒΆ added in v0.3.1

func NewSemaphore(n int) Semaphore

NewSemaphore creates a semaphore that allows up to a given limit of simultaneous acquisitions

func (Semaphore) Acquire ΒΆ added in v0.3.1

func (s Semaphore) Acquire()

Acquire is used to acquire an available slot. Blocks until available.

func (Semaphore) Release ΒΆ added in v0.3.1

func (s Semaphore) Release()

Release is used to return a slot. Acquire must be called as a pre-condition.

func (Semaphore) TryAcquire ΒΆ added in v0.3.1

func (s Semaphore) TryAcquire() bool

TryAcquire is used to do a non-blocking acquire. Returns a bool indicating success

type State ΒΆ

type State struct {
	// Version is the protocol version. Currently only "1".
	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"`

	// Remote is used to track the metadata required to
	// pull and push state files from a remote storage endpoint.
	Remote *RemoteState `json:"remote,omitempty"`

	// Modules contains all the modules in a breadth-first order
	Modules []*ModuleState `json:"modules"`
}

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. This is the latest format as of Terraform 0.3

func NewState ΒΆ added in v0.3.5

func NewState() *State

NewState is used to initialize a blank state

func ReadState ΒΆ

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 ΒΆ

func ReadStateV2(jsonBytes []byte) (*State, error)

func (*State) Add ΒΆ

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 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 ΒΆ added in v0.3.0

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) Children ΒΆ added in v0.3.0

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) DeepCopy ΒΆ added in v0.4.0

func (s *State) DeepCopy() *State

DeepCopy performs a deep copy of the state structure and returns a new structure.

func (*State) Empty ΒΆ added in v0.4.0

func (s *State) Empty() bool

Empty returns true if the state is empty.

func (*State) Equal ΒΆ added in v0.4.0

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

Equal tests if one state is equal to another.

func (*State) FromFutureTerraform ΒΆ

func (s *State) FromFutureTerraform() bool

FromFutureTerraform checks if this state was written by a Terraform version from the future.

func (*State) GoString ΒΆ added in v0.3.0

func (s *State) GoString() string

func (*State) IncrementSerialMaybe ΒΆ added in v0.4.0

func (s *State) IncrementSerialMaybe(other *State)

IncrementSerialMaybe increments the serial number of this state if it different from the other state.

func (*State) IsRemote ΒΆ added in v0.4.0

func (s *State) IsRemote() bool

IsRemote returns true if State represents a state that exists and is remote.

func (*State) ModuleByPath ΒΆ added in v0.3.0

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 ΒΆ added in v0.4.0

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 ΒΆ

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 ΒΆ added in v0.3.0

func (s *State) RootModule() *ModuleState

RootModule returns the ModuleState for the root module

func (*State) String ΒΆ

func (s *State) String() string

type StateFilter ΒΆ

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 ΒΆ

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 ΒΆ

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 ΒΆ

func (r *StateFilterResult) String() string

type StateFilterResultSlice ΒΆ

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 ΒΆ

func (s StateFilterResultSlice) Len() int

func (StateFilterResultSlice) Less ΒΆ

func (s StateFilterResultSlice) Less(i, j int) bool

func (StateFilterResultSlice) Swap ΒΆ

func (s StateFilterResultSlice) Swap(i, j int)

type StateV0 ΒΆ

type StateV0 struct {
	Outputs   map[string]string
	Resources map[string]*ResourceStateV0
	Tainted   map[string]struct{}
	// contains filtered or unexported fields
}

StateV0 is used to represent the state of Terraform files before 0.3. It is automatically upgraded to a modern State representation on start.

func ReadStateV0 ΒΆ

func ReadStateV0(src io.Reader) (*StateV0, error)

ReadStateV0 reads a state structure out of a reader in the format that was written by WriteState.

func (*StateV0) Orphans ΒΆ

func (s *StateV0) 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 (*StateV0) String ΒΆ

func (s *StateV0) String() string

type TargetsTransformer ΒΆ added in v0.4.0

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

	// 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 ΒΆ added in v0.4.0

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

type TransitiveReductionTransformer ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

type UIInput ΒΆ added in v0.3.0

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 ΒΆ added in v0.3.0

type UIOutput interface {
	Output(string)
}

UIOutput is the interface that must be implemented to output data to the end user.

type UnorderedSemanticCheckRunner ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

type VertexTransformer ΒΆ added in v0.4.0

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 ΒΆ added in v0.4.0

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

Source Files ΒΆ

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL