Documentation ¶
Index ¶
- Constants
- Variables
- func CheckCoreVersionRequirements(config *configs.Config) tfdiags.Diagnostics
- func ConfigTreeDependencies(root *configs.Config, state *states.State) *moduledeps.Module
- func ConnectionBlockSupersetSchema() *configschema.Block
- func Eval(n EvalNode, ctx EvalContext) (interface{}, error)
- func EvalRaw(n EvalNode, ctx EvalContext) (interface{}, error)
- func GraphDot(g *Graph, opts *dag.DotOpts) (string, error)
- func MustShimLegacyState(legacy *State) *states.State
- func ParseResourceIndex(s string) (int, error)
- func ParseResourcePath(s string) []string
- func PathObjectCacheKey(path addrs.ModuleInstance, objectName string) string
- func ProviderHasDataSource(p ResourceProvider, n string) bool
- func ProviderHasResource(p ResourceProvider, n string) bool
- func ReadStateV1(jsonBytes []byte) (*stateV1, error)
- func ReferencesFromConfig(body hcl.Body, schema *configschema.Block) []*addrs.Reference
- func ShimLegacyState(legacy *State) (*states.State, error)
- func TestStateFile(t *testing.T, path string, state *State)
- func UpgradeResourceState(addr addrs.AbsResourceInstance, provider providers.Interface, ...) (*states.ResourceInstanceObjectSrc, tfdiags.Diagnostics)
- func WritePlan(d *Plan, dst io.Writer) error
- func WriteState(d *State, dst io.Writer) error
- type ApplyGraphBuilder
- type AttachResourceConfigTransformer
- type AttachSchemaTransformer
- type AttachStateTransformer
- type BackendState
- type BasicGraphBuilder
- type BuiltinEvalContext
- func (ctx *BuiltinEvalContext) Changes() *plans.ChangesSync
- func (ctx *BuiltinEvalContext) CloseProvider(addr addrs.ProviderConfig) error
- func (ctx *BuiltinEvalContext) CloseProvisioner(n string) error
- func (ctx *BuiltinEvalContext) ConfigureProvider(addr addrs.ProviderConfig, cfg cty.Value) tfdiags.Diagnostics
- func (ctx *BuiltinEvalContext) EvaluateBlock(body hcl.Body, schema *configschema.Block, self addrs.Referenceable, ...) (cty.Value, hcl.Body, tfdiags.Diagnostics)
- func (ctx *BuiltinEvalContext) EvaluateExpr(expr hcl.Expression, wantType cty.Type, self addrs.Referenceable) (cty.Value, tfdiags.Diagnostics)
- func (ctx *BuiltinEvalContext) EvaluationScope(self addrs.Referenceable, keyData InstanceKeyEvalData) *lang.Scope
- func (ctx *BuiltinEvalContext) Hook(fn func(Hook) (HookAction, error)) error
- func (ctx *BuiltinEvalContext) InitProvider(typeName string, addr addrs.ProviderConfig) (providers.Interface, error)
- func (ctx *BuiltinEvalContext) InitProvisioner(n string) (provisioners.Interface, error)
- func (ctx *BuiltinEvalContext) Input() UIInput
- func (ctx *BuiltinEvalContext) Path() addrs.ModuleInstance
- func (ctx *BuiltinEvalContext) Provider(addr addrs.AbsProviderConfig) providers.Interface
- func (ctx *BuiltinEvalContext) ProviderInput(pc addrs.ProviderConfig) map[string]cty.Value
- func (ctx *BuiltinEvalContext) ProviderSchema(addr addrs.AbsProviderConfig) *ProviderSchema
- func (ctx *BuiltinEvalContext) Provisioner(n string) provisioners.Interface
- func (ctx *BuiltinEvalContext) ProvisionerSchema(n string) *configschema.Block
- func (ctx *BuiltinEvalContext) SetModuleCallArguments(n addrs.ModuleCallInstance, vals map[string]cty.Value)
- func (ctx *BuiltinEvalContext) SetProviderInput(pc addrs.ProviderConfig, c map[string]cty.Value)
- func (ctx *BuiltinEvalContext) State() *states.SyncState
- func (ctx *BuiltinEvalContext) Stopped() <-chan struct{}
- type CBDEdgeTransformer
- type CallbackUIOutput
- type CloseProviderTransformer
- type CloseProvisionerTransformer
- type ConcreteProviderNodeFunc
- type ConcreteResourceInstanceDeposedNodeFunc
- type ConcreteResourceInstanceNodeFunc
- type ConcreteResourceNodeFunc
- type ConfigTransformer
- type Context
- func (c *Context) Apply() (*states.State, tfdiags.Diagnostics)
- func (c *Context) Config() *configs.Config
- func (c *Context) Eval(path addrs.ModuleInstance) (*lang.Scope, tfdiags.Diagnostics)
- func (c *Context) Graph(typ GraphType, opts *ContextGraphOpts) (*Graph, tfdiags.Diagnostics)
- func (c *Context) Import(opts *ImportOpts) (*states.State, tfdiags.Diagnostics)
- func (c *Context) Input(mode InputMode) tfdiags.Diagnostics
- func (c *Context) Plan() (*plans.Plan, tfdiags.Diagnostics)
- func (c *Context) Refresh() (*states.State, tfdiags.Diagnostics)
- func (c *Context) Schemas() *Schemas
- func (c *Context) SetVariable(k string, v cty.Value)
- func (c *Context) ShadowError() error
- func (c *Context) State() *states.State
- func (c *Context) Stop()
- func (c *Context) Validate() tfdiags.Diagnostics
- func (c *Context) Variables() InputValues
- type ContextGraphOpts
- type ContextGraphWalker
- type ContextMeta
- type ContextOpts
- type CountBoundaryTransformer
- type DataSource
- type DestroyEdge
- type DestroyEdgeTransformer
- type DestroyOutputTransformer
- type DestroyPlanGraphBuilder
- type DestroyValueReferenceTransformer
- type Diff
- func (d *Diff) AddModule(path addrs.ModuleInstance) *ModuleDiff
- func (d *Diff) DeepCopy() *Diff
- func (d *Diff) Empty() bool
- func (d *Diff) Equal(d2 *Diff) bool
- func (d *Diff) ModuleByPath(path addrs.ModuleInstance) *ModuleDiff
- func (d *Diff) Prune()
- func (d *Diff) RootModule() *ModuleDiff
- func (d *Diff) String() string
- type DiffAttrType
- type DiffChangeType
- type DiffTransformer
- type EphemeralState
- type EvalApply
- type EvalApplyPost
- type EvalApplyPre
- type EvalApplyProvisioners
- type EvalCheckModuleRemoved
- type EvalCheckPlannedChange
- type EvalCheckPreventDestroy
- type EvalCloseProvider
- type EvalCloseProvisioner
- type EvalConfigBlock
- type EvalConfigExpr
- type EvalConfigProvider
- type EvalContext
- type EvalCountFixZeroOneBoundaryGlobal
- type EvalDeleteLocal
- type EvalDeleteOutput
- type EvalDeposeState
- type EvalDiff
- type EvalDiffDestroy
- type EvalEarlyExitError
- type EvalForgetResourceState
- type EvalGetProvider
- type EvalGetProvisioner
- type EvalGraphBuilder
- type EvalIf
- type EvalImportState
- type EvalImportStateVerify
- type EvalInitProvider
- type EvalInitProvisioner
- type EvalLocal
- type EvalMaybeRestoreDeposedObject
- type EvalMaybeTainted
- type EvalModuleCallArgument
- type EvalNode
- type EvalNodeFilterFunc
- type EvalNodeFilterable
- type EvalNodeOpFilterable
- type EvalNoop
- type EvalOpFilter
- type EvalReadData
- type EvalReadDataApply
- type EvalReadDiff
- type EvalReadState
- type EvalReadStateDeposed
- type EvalReduceDiff
- type EvalRefresh
- type EvalRequireState
- type EvalReturnError
- type EvalSequence
- type EvalSetModuleCallArguments
- type EvalUpdateStateHook
- type EvalValidateCount
- type EvalValidateProvider
- type EvalValidateProvisioner
- type EvalValidateResource
- type EvalValidateSelfRef
- type EvalWriteDiff
- type EvalWriteOutput
- type EvalWriteResourceState
- type EvalWriteState
- type EvalWriteStateDeposed
- type Evaluator
- type ExpandTransform
- type ForcedCBDTransformer
- type Graph
- type GraphBuilder
- type GraphNodeAttachDestroyer
- type GraphNodeAttachProvider
- type GraphNodeAttachProviderConfigSchema
- type GraphNodeAttachProvisionerSchema
- type GraphNodeAttachResourceConfig
- type GraphNodeAttachResourceSchema
- type GraphNodeAttachResourceState
- type GraphNodeCloseProvider
- type GraphNodeCloseProvisioner
- type GraphNodeCreator
- type GraphNodeDeposedResourceInstanceObject
- type GraphNodeDeposer
- type GraphNodeDestroyer
- type GraphNodeDestroyerCBD
- type GraphNodeDynamicExpandable
- type GraphNodeEvalable
- type GraphNodeExpandable
- type GraphNodeProvider
- type GraphNodeProviderConsumer
- type GraphNodeProvisioner
- type GraphNodeProvisionerConsumer
- type GraphNodeReferenceOutside
- type GraphNodeReferenceable
- type GraphNodeReferencer
- type GraphNodeResource
- type GraphNodeResourceInstance
- type GraphNodeSubPath
- type GraphNodeSubgraph
- type GraphNodeTargetDownstream
- type GraphNodeTargetable
- type GraphTransformer
- type GraphType
- type GraphVertexTransformer
- type GraphWalker
- type Hook
- type HookAction
- type ImportGraphBuilder
- type ImportOpts
- type ImportProviderValidateTransformer
- type ImportStateTransformer
- type ImportTarget
- type InputMode
- type InputOpts
- type InputValue
- type InputValues
- type InstanceDiff
- func (d *InstanceDiff) Apply(attrs map[string]string, schema *configschema.Block) (map[string]string, error)
- func (d *InstanceDiff) ApplyToValue(base cty.Value, schema *configschema.Block) (cty.Value, error)
- func (d *InstanceDiff) ChangeType() DiffChangeType
- func (d *InstanceDiff) Copy() (*InstanceDiff, error)
- func (d *InstanceDiff) CopyAttributes() map[string]*ResourceAttrDiff
- func (d *InstanceDiff) DeepCopy() *InstanceDiff
- func (d *InstanceDiff) DelAttribute(key string)
- func (d *InstanceDiff) Empty() bool
- func (d *InstanceDiff) Equal(d2 *InstanceDiff) bool
- func (d *InstanceDiff) GetAttribute(key string) (*ResourceAttrDiff, bool)
- func (d *InstanceDiff) GetAttributesLen() int
- func (d *InstanceDiff) GetDestroy() bool
- func (d *InstanceDiff) GetDestroyDeposed() bool
- func (d *InstanceDiff) GetDestroyTainted() bool
- func (d *InstanceDiff) GoString() string
- func (d *InstanceDiff) Lock()
- func (d *InstanceDiff) RequiresNew() bool
- func (d *InstanceDiff) Same(d2 *InstanceDiff) (bool, string)
- func (d *InstanceDiff) SetAttribute(key string, attr *ResourceAttrDiff)
- func (d *InstanceDiff) SetDestroy(b bool)
- func (d *InstanceDiff) SetDestroyDeposed(b bool)
- func (d *InstanceDiff) SetTainted(b bool)
- func (d *InstanceDiff) Unlock()
- type InstanceInfo
- type InstanceKeyEvalData
- type InstanceState
- func (s *InstanceState) AttrsAsObjectValue(ty cty.Type) (cty.Value, error)
- func (s *InstanceState) DeepCopy() *InstanceState
- func (s *InstanceState) Empty() bool
- func (s *InstanceState) Equal(other *InstanceState) bool
- func (s *InstanceState) Lock()
- func (s *InstanceState) MergeDiff(d *InstanceDiff) *InstanceState
- func (s *InstanceState) Set(from *InstanceState)
- func (s *InstanceState) String() string
- func (s *InstanceState) Unlock()
- type InstanceType
- type LocalTransformer
- type MissingProviderTransformer
- type MissingProvisionerTransformer
- type MockEvalContext
- func (c *MockEvalContext) Changes() *plans.ChangesSync
- func (c *MockEvalContext) CloseProvider(addr addrs.ProviderConfig) error
- func (c *MockEvalContext) CloseProvisioner(n string) error
- func (c *MockEvalContext) ConfigureProvider(addr addrs.ProviderConfig, cfg cty.Value) tfdiags.Diagnostics
- func (c *MockEvalContext) EvaluateBlock(body hcl.Body, schema *configschema.Block, self addrs.Referenceable, ...) (cty.Value, hcl.Body, tfdiags.Diagnostics)
- func (c *MockEvalContext) EvaluateExpr(expr hcl.Expression, wantType cty.Type, self addrs.Referenceable) (cty.Value, tfdiags.Diagnostics)
- func (c *MockEvalContext) EvaluationScope(self addrs.Referenceable, keyData InstanceKeyEvalData) *lang.Scope
- func (c *MockEvalContext) Hook(fn func(Hook) (HookAction, error)) error
- func (c *MockEvalContext) InitProvider(t string, addr addrs.ProviderConfig) (providers.Interface, error)
- func (c *MockEvalContext) InitProvisioner(n string) (provisioners.Interface, error)
- func (c *MockEvalContext) Input() UIInput
- func (c *MockEvalContext) Path() addrs.ModuleInstance
- func (c *MockEvalContext) Provider(addr addrs.AbsProviderConfig) providers.Interface
- func (c *MockEvalContext) ProviderInput(addr addrs.ProviderConfig) map[string]cty.Value
- func (c *MockEvalContext) ProviderSchema(addr addrs.AbsProviderConfig) *ProviderSchema
- func (c *MockEvalContext) Provisioner(n string) provisioners.Interface
- func (c *MockEvalContext) ProvisionerSchema(n string) *configschema.Block
- func (c *MockEvalContext) SetModuleCallArguments(n addrs.ModuleCallInstance, values map[string]cty.Value)
- func (c *MockEvalContext) SetProviderInput(addr addrs.ProviderConfig, vals map[string]cty.Value)
- func (c *MockEvalContext) State() *states.SyncState
- func (c *MockEvalContext) Stopped() <-chan struct{}
- type MockHook
- func (h *MockHook) PostApply(addr addrs.AbsResourceInstance, gen states.Generation, newState cty.Value, ...) (HookAction, error)
- func (h *MockHook) PostDiff(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, ...) (HookAction, error)
- func (h *MockHook) PostImportState(addr addrs.AbsResourceInstance, imported []providers.ImportedResource) (HookAction, error)
- func (h *MockHook) PostProvisionInstance(addr addrs.AbsResourceInstance, state cty.Value) (HookAction, error)
- func (h *MockHook) PostProvisionInstanceStep(addr addrs.AbsResourceInstance, typeName string, err error) (HookAction, error)
- func (h *MockHook) PostRefresh(addr addrs.AbsResourceInstance, gen states.Generation, priorState cty.Value, ...) (HookAction, error)
- func (h *MockHook) PostStateUpdate(new *states.State) (HookAction, error)
- func (h *MockHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, ...) (HookAction, error)
- func (h *MockHook) PreDiff(addr addrs.AbsResourceInstance, gen states.Generation, ...) (HookAction, error)
- func (h *MockHook) PreImportState(addr addrs.AbsResourceInstance, importID string) (HookAction, error)
- func (h *MockHook) PreProvisionInstance(addr addrs.AbsResourceInstance, state cty.Value) (HookAction, error)
- func (h *MockHook) PreProvisionInstanceStep(addr addrs.AbsResourceInstance, typeName string) (HookAction, error)
- func (h *MockHook) PreRefresh(addr addrs.AbsResourceInstance, gen states.Generation, priorState cty.Value) (HookAction, error)
- func (h *MockHook) ProvisionOutput(addr addrs.AbsResourceInstance, typeName string, line string)
- type MockProvider
- func (p *MockProvider) ApplyResourceChange(r providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse
- func (p *MockProvider) Close() error
- func (p *MockProvider) Configure(r providers.ConfigureRequest) providers.ConfigureResponse
- func (p *MockProvider) GetSchema() providers.GetSchemaResponse
- func (p *MockProvider) ImportResourceState(r providers.ImportResourceStateRequest) providers.ImportResourceStateResponse
- func (p *MockProvider) PlanResourceChange(r providers.PlanResourceChangeRequest) providers.PlanResourceChangeResponse
- func (p *MockProvider) PrepareProviderConfig(r providers.PrepareProviderConfigRequest) providers.PrepareProviderConfigResponse
- func (p *MockProvider) ReadDataSource(r providers.ReadDataSourceRequest) providers.ReadDataSourceResponse
- func (p *MockProvider) ReadResource(r providers.ReadResourceRequest) providers.ReadResourceResponse
- func (p *MockProvider) Stop() error
- func (p *MockProvider) UpgradeResourceState(r providers.UpgradeResourceStateRequest) providers.UpgradeResourceStateResponse
- func (p *MockProvider) ValidateDataSourceConfig(r providers.ValidateDataSourceConfigRequest) providers.ValidateDataSourceConfigResponse
- func (p *MockProvider) ValidateResourceTypeConfig(r providers.ValidateResourceTypeConfigRequest) providers.ValidateResourceTypeConfigResponse
- type MockProvisioner
- func (p *MockProvisioner) Close() error
- func (p *MockProvisioner) GetSchema() provisioners.GetSchemaResponse
- func (p *MockProvisioner) ProvisionResource(r provisioners.ProvisionResourceRequest) provisioners.ProvisionResourceResponse
- func (p *MockProvisioner) Stop() error
- func (p *MockProvisioner) ValidateProvisionerConfig(r provisioners.ValidateProvisionerConfigRequest) provisioners.ValidateProvisionerConfigResponse
- type MockResourceProvider
- func (p *MockResourceProvider) Apply(info *InstanceInfo, state *InstanceState, diff *InstanceDiff) (*InstanceState, error)
- func (p *MockResourceProvider) Close() error
- func (p *MockResourceProvider) Configure(c *ResourceConfig) error
- func (p *MockResourceProvider) DataSources() []DataSource
- func (p *MockResourceProvider) Diff(info *InstanceInfo, state *InstanceState, desired *ResourceConfig) (*InstanceDiff, error)
- func (p *MockResourceProvider) GetSchema(req *ProviderSchemaRequest) (*ProviderSchema, error)
- func (p *MockResourceProvider) ImportState(info *InstanceInfo, id string) ([]*InstanceState, error)
- func (p *MockResourceProvider) Input(input UIInput, c *ResourceConfig) (*ResourceConfig, error)
- func (p *MockResourceProvider) ReadDataApply(info *InstanceInfo, d *InstanceDiff) (*InstanceState, error)
- func (p *MockResourceProvider) ReadDataDiff(info *InstanceInfo, desired *ResourceConfig) (*InstanceDiff, error)
- func (p *MockResourceProvider) Refresh(info *InstanceInfo, s *InstanceState) (*InstanceState, error)
- func (p *MockResourceProvider) Resources() []ResourceType
- func (p *MockResourceProvider) Stop() error
- func (p *MockResourceProvider) Validate(c *ResourceConfig) ([]string, []error)
- func (p *MockResourceProvider) ValidateDataSource(t string, c *ResourceConfig) ([]string, []error)
- func (p *MockResourceProvider) ValidateResource(t string, c *ResourceConfig) ([]string, []error)
- type MockResourceProvisioner
- func (p *MockResourceProvisioner) Apply(output UIOutput, state *InstanceState, c *ResourceConfig) error
- func (p *MockResourceProvisioner) GetConfigSchema() (*configschema.Block, error)
- func (p *MockResourceProvisioner) Stop() error
- func (p *MockResourceProvisioner) Validate(c *ResourceConfig) ([]string, []error)
- type MockUIInput
- type MockUIOutput
- type ModuleDiff
- type ModuleState
- func (m *ModuleState) Empty() bool
- func (m *ModuleState) Equal(other *ModuleState) bool
- func (m *ModuleState) IsDescendent(other *ModuleState) bool
- func (m *ModuleState) IsRoot() bool
- func (s *ModuleState) Lock()
- func (m *ModuleState) Orphans(c *configs.Module) []addrs.ResourceInstance
- func (s *ModuleState) RemovedOutputs(outputs map[string]*configs.Output) []addrs.OutputValue
- func (m *ModuleState) String() string
- func (s *ModuleState) Unlock()
- func (m *ModuleState) View(id string) *ModuleState
- type ModuleVariableTransformer
- type NilHook
- func (*NilHook) PostApply(addr addrs.AbsResourceInstance, gen states.Generation, newState cty.Value, ...) (HookAction, error)
- func (*NilHook) PostDiff(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, ...) (HookAction, error)
- func (*NilHook) PostImportState(addr addrs.AbsResourceInstance, imported []providers.ImportedResource) (HookAction, error)
- func (*NilHook) PostProvisionInstance(addr addrs.AbsResourceInstance, state cty.Value) (HookAction, error)
- func (*NilHook) PostProvisionInstanceStep(addr addrs.AbsResourceInstance, typeName string, err error) (HookAction, error)
- func (*NilHook) PostRefresh(addr addrs.AbsResourceInstance, gen states.Generation, priorState cty.Value, ...) (HookAction, error)
- func (*NilHook) PostStateUpdate(new *states.State) (HookAction, error)
- func (*NilHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, ...) (HookAction, error)
- func (*NilHook) PreDiff(addr addrs.AbsResourceInstance, gen states.Generation, ...) (HookAction, error)
- func (*NilHook) PreImportState(addr addrs.AbsResourceInstance, importID string) (HookAction, error)
- func (*NilHook) PreProvisionInstance(addr addrs.AbsResourceInstance, state cty.Value) (HookAction, error)
- func (*NilHook) PreProvisionInstanceStep(addr addrs.AbsResourceInstance, typeName string) (HookAction, error)
- func (*NilHook) PreRefresh(addr addrs.AbsResourceInstance, gen states.Generation, priorState cty.Value) (HookAction, error)
- func (*NilHook) ProvisionOutput(addr addrs.AbsResourceInstance, typeName string, line string)
- type NodeAbstractProvider
- func (n *NodeAbstractProvider) AttachProvider(c *configs.Provider)
- func (n *NodeAbstractProvider) AttachProviderConfigSchema(schema *configschema.Block)
- func (n *NodeAbstractProvider) DotNode(name string, opts *dag.DotOpts) *dag.DotNode
- func (n *NodeAbstractProvider) Name() string
- func (n *NodeAbstractProvider) Path() addrs.ModuleInstance
- func (n *NodeAbstractProvider) ProviderAddr() addrs.AbsProviderConfig
- func (n *NodeAbstractProvider) ProviderConfig() *configs.Provider
- func (n *NodeAbstractProvider) References() []*addrs.Reference
- func (n *NodeAbstractProvider) RemoveIfNotTargeted() bool
- type NodeAbstractResource
- func (n *NodeAbstractResource) AttachProvisionerSchema(name string, schema *configschema.Block)
- func (n *NodeAbstractResource) AttachResourceConfig(c *configs.Resource)
- func (n *NodeAbstractResource) AttachResourceSchema(schema *configschema.Block, version uint64)
- func (n *NodeAbstractResource) DotNode(name string, opts *dag.DotOpts) *dag.DotNode
- func (n *NodeAbstractResource) Name() string
- func (n *NodeAbstractResource) Path() addrs.ModuleInstance
- func (n *NodeAbstractResource) ProvidedBy() (addrs.AbsProviderConfig, bool)
- func (n *NodeAbstractResource) ProvisionedBy() []string
- func (n *NodeAbstractResource) ReferenceableAddrs() []addrs.Referenceable
- func (n *NodeAbstractResource) References() []*addrs.Reference
- func (n *NodeAbstractResource) ResourceAddr() addrs.AbsResource
- func (n *NodeAbstractResource) ResourceAddress() *ResourceAddress
- func (n *NodeAbstractResource) SetProvider(p addrs.AbsProviderConfig)
- func (n *NodeAbstractResource) SetTargets(targets []addrs.Targetable)
- type NodeAbstractResourceInstance
- func (n *NodeAbstractResourceInstance) AttachResourceState(s *states.Resource)
- func (n *NodeAbstractResourceInstance) Name() string
- func (n *NodeAbstractResourceInstance) ProvidedBy() (addrs.AbsProviderConfig, bool)
- func (n *NodeAbstractResourceInstance) ReferenceableAddrs() []addrs.Referenceable
- func (n *NodeAbstractResourceInstance) References() []*addrs.Reference
- func (n *NodeAbstractResourceInstance) ResourceInstanceAddr() addrs.AbsResourceInstance
- func (n *NodeAbstractResourceInstance) StateReferences() []addrs.Referenceable
- type NodeApplyableModuleVariable
- func (n *NodeApplyableModuleVariable) DotNode(name string, opts *dag.DotOpts) *dag.DotNode
- func (n *NodeApplyableModuleVariable) EvalTree() EvalNode
- func (n *NodeApplyableModuleVariable) Name() string
- func (n *NodeApplyableModuleVariable) Path() addrs.ModuleInstance
- func (n *NodeApplyableModuleVariable) ReferenceOutside() (selfPath, referencePath addrs.ModuleInstance)
- func (n *NodeApplyableModuleVariable) ReferenceableAddrs() []addrs.Referenceable
- func (n *NodeApplyableModuleVariable) References() []*addrs.Reference
- func (n *NodeApplyableModuleVariable) RemoveIfNotTargeted() bool
- type NodeApplyableOutput
- func (n *NodeApplyableOutput) DotNode(name string, opts *dag.DotOpts) *dag.DotNode
- func (n *NodeApplyableOutput) EvalTree() EvalNode
- func (n *NodeApplyableOutput) Name() string
- func (n *NodeApplyableOutput) Path() addrs.ModuleInstance
- func (n *NodeApplyableOutput) ReferenceOutside() (selfPath, referencePath addrs.ModuleInstance)
- func (n *NodeApplyableOutput) ReferenceableAddrs() []addrs.Referenceable
- func (n *NodeApplyableOutput) References() []*addrs.Reference
- func (n *NodeApplyableOutput) RemoveIfNotTargeted() bool
- func (n *NodeApplyableOutput) TargetDownstream(targetedDeps, untargetedDeps *dag.Set) bool
- type NodeApplyableProvider
- type NodeApplyableResource
- type NodeApplyableResourceInstance
- func (n *NodeApplyableResourceInstance) AttachDestroyNode(d GraphNodeDestroyerCBD)
- func (n *NodeApplyableResourceInstance) CreateAddr() *addrs.AbsResourceInstance
- func (n *NodeApplyableResourceInstance) EvalTree() EvalNode
- func (n *NodeApplyableResourceInstance) References() []*addrs.Reference
- func (n *NodeApplyableResourceInstance) SetPreallocatedDeposedKey(key states.DeposedKey)
- type NodeCountBoundary
- type NodeDestroyDeposedResourceInstanceObject
- func (n *NodeDestroyDeposedResourceInstanceObject) CreateBeforeDestroy() bool
- func (n *NodeDestroyDeposedResourceInstanceObject) DeposedInstanceObjectKey() states.DeposedKey
- func (n *NodeDestroyDeposedResourceInstanceObject) DestroyAddr() *addrs.AbsResourceInstance
- func (n *NodeDestroyDeposedResourceInstanceObject) EvalTree() EvalNode
- func (n *NodeDestroyDeposedResourceInstanceObject) ModifyCreateBeforeDestroy(v bool) error
- func (n *NodeDestroyDeposedResourceInstanceObject) Name() string
- func (n *NodeDestroyDeposedResourceInstanceObject) ReferenceableAddrs() []addrs.Referenceable
- func (n *NodeDestroyDeposedResourceInstanceObject) References() []*addrs.Reference
- type NodeDestroyResource
- type NodeDestroyResourceInstance
- func (n *NodeDestroyResourceInstance) CreateBeforeDestroy() bool
- func (n *NodeDestroyResourceInstance) DestroyAddr() *addrs.AbsResourceInstance
- func (n *NodeDestroyResourceInstance) EvalTree() EvalNode
- func (n *NodeDestroyResourceInstance) ModifyCreateBeforeDestroy(v bool) error
- func (n *NodeDestroyResourceInstance) Name() string
- func (n *NodeDestroyResourceInstance) ReferenceableAddrs() []addrs.Referenceable
- func (n *NodeDestroyResourceInstance) References() []*addrs.Reference
- type NodeDestroyableDataResourceInstance
- type NodeDestroyableOutput
- func (n *NodeDestroyableOutput) DotNode(name string, opts *dag.DotOpts) *dag.DotNode
- func (n *NodeDestroyableOutput) EvalTree() EvalNode
- func (n *NodeDestroyableOutput) Name() string
- func (n *NodeDestroyableOutput) Path() addrs.ModuleInstance
- func (n *NodeDestroyableOutput) References() []*addrs.Reference
- func (n *NodeDestroyableOutput) RemoveIfNotTargeted() bool
- func (n *NodeDestroyableOutput) TargetDownstream(targetedDeps, untargetedDeps *dag.Set) bool
- type NodeDisabledProvider
- type NodeEvalableProvider
- type NodeLocal
- func (n *NodeLocal) DotNode(name string, opts *dag.DotOpts) *dag.DotNode
- func (n *NodeLocal) EvalTree() EvalNode
- func (n *NodeLocal) Name() string
- func (n *NodeLocal) Path() addrs.ModuleInstance
- func (n *NodeLocal) ReferenceableAddrs() []addrs.Referenceable
- func (n *NodeLocal) References() []*addrs.Reference
- func (n *NodeLocal) RemoveIfNotTargeted() bool
- type NodeModuleRemoved
- func (n *NodeModuleRemoved) EvalTree() EvalNode
- func (n *NodeModuleRemoved) Name() string
- func (n *NodeModuleRemoved) Path() addrs.ModuleInstance
- func (n *NodeModuleRemoved) ReferenceOutside() (selfPath, referencePath addrs.ModuleInstance)
- func (n *NodeModuleRemoved) References() []*addrs.Reference
- func (n *NodeModuleRemoved) RemoveIfNotTargeted() bool
- type NodeOutputOrphan
- func (n *NodeOutputOrphan) EvalTree() EvalNode
- func (n *NodeOutputOrphan) Name() string
- func (n *NodeOutputOrphan) Path() addrs.ModuleInstance
- func (n *NodeOutputOrphan) ReferenceOutside() (selfPath, referencePath addrs.ModuleInstance)
- func (n *NodeOutputOrphan) ReferenceableAddrs() []addrs.Referenceable
- type NodePlanDeposedResourceInstanceObject
- func (n *NodePlanDeposedResourceInstanceObject) DeposedInstanceObjectKey() states.DeposedKey
- func (n *NodePlanDeposedResourceInstanceObject) EvalTree() EvalNode
- func (n *NodePlanDeposedResourceInstanceObject) Name() string
- func (n *NodePlanDeposedResourceInstanceObject) ReferenceableAddrs() []addrs.Referenceable
- func (n *NodePlanDeposedResourceInstanceObject) References() []*addrs.Reference
- type NodePlanDestroyableResourceInstance
- type NodePlannableResource
- type NodePlannableResourceInstance
- type NodePlannableResourceInstanceOrphan
- type NodeProvisioner
- type NodeRefreshableDataResource
- type NodeRefreshableDataResourceInstance
- type NodeRefreshableManagedResource
- type NodeRefreshableManagedResourceInstance
- type NodeRootVariable
- type NodeValidatableResource
- type NullGraphWalker
- func (NullGraphWalker) EnterEvalTree(v dag.Vertex, n EvalNode) EvalNode
- func (NullGraphWalker) EnterPath(addrs.ModuleInstance) EvalContext
- func (NullGraphWalker) EnterVertex(dag.Vertex)
- func (NullGraphWalker) ExitEvalTree(dag.Vertex, interface{}, error) tfdiags.Diagnostics
- func (NullGraphWalker) ExitPath(addrs.ModuleInstance)
- func (NullGraphWalker) ExitVertex(dag.Vertex, tfdiags.Diagnostics)
- type OrphanOutputTransformer
- type OrphanResourceCountTransformer
- type OrphanResourceInstanceTransformer
- type OrphanResourceTransformer
- type OutputState
- type OutputTransformer
- type ParentProviderTransformer
- type Plan
- type PlanGraphBuilder
- type PrefixUIInput
- type ProviderConfigTransformer
- type ProviderSchema
- type ProviderSchemaRequest
- type ProviderTransformer
- type ProvisionerFactory
- type ProvisionerTransformer
- type ProvisionerUIOutput
- type PruneProviderTransformer
- type PruneUnusedValuesTransformer
- type ReferenceMap
- type ReferenceTransformer
- type RefreshGraphBuilder
- type RemoteState
- type RemovableIfNotTargeted
- type RemovedModuleTransformer
- type Resource
- type ResourceAddress
- func NewLegacyResourceAddress(addr addrs.AbsResource) *ResourceAddress
- func NewLegacyResourceInstanceAddress(addr addrs.AbsResourceInstance) *ResourceAddress
- func ParseResourceAddress(s string) (*ResourceAddress, error)
- func ParseResourceAddressForInstanceDiff(path []string, key string) (*ResourceAddress, error)
- func (addr *ResourceAddress) AbsResourceInstanceAddr() addrs.AbsResourceInstance
- func (addr *ResourceAddress) Contains(other *ResourceAddress) bool
- func (r *ResourceAddress) Copy() *ResourceAddress
- func (addr *ResourceAddress) Equals(raw interface{}) bool
- func (r *ResourceAddress) HasResourceSpec() bool
- func (addr *ResourceAddress) Less(other *ResourceAddress) bool
- func (r *ResourceAddress) MatchesResourceConfig(path addrs.Module, rc *configs.Resource) bool
- func (addr *ResourceAddress) ModuleInstanceAddr() addrs.ModuleInstance
- func (r *ResourceAddress) String() string
- func (r *ResourceAddress) WholeModuleAddress() *ResourceAddress
- type ResourceAttrDiff
- type ResourceConfig
- func (c *ResourceConfig) CheckSet(keys []string) []error
- func (c *ResourceConfig) DeepCopy() *ResourceConfig
- func (c *ResourceConfig) Equal(c2 *ResourceConfig) bool
- func (c *ResourceConfig) Get(k string) (interface{}, bool)
- func (c *ResourceConfig) GetRaw(k string) (interface{}, bool)
- func (c *ResourceConfig) IsComputed(k string) bool
- func (c *ResourceConfig) IsSet(k string) bool
- type ResourceCountTransformer
- type ResourceFlag
- type ResourceMode
- type ResourceProvider
- type ResourceProviderCloser
- type ResourceProviderFactory
- type ResourceProviderResolver
- type ResourceProviderResolverFunc
- type ResourceProvisioner
- type ResourceProvisionerCloser
- type ResourceProvisionerFactory
- type ResourceState
- type ResourceStateKey
- type ResourceType
- type RootTransformer
- type RootVariableTransformer
- type Schemas
- func (ss *Schemas) ProviderConfig(typeName string) *configschema.Block
- func (ss *Schemas) ProviderSchema(typeName string) *ProviderSchema
- func (ss *Schemas) ProvisionerConfig(name string) *configschema.Block
- func (ss *Schemas) ResourceTypeConfig(providerType string, resourceMode addrs.ResourceMode, resourceType string) (block *configschema.Block, schemaVersion uint64)
- type Semaphore
- type State
- func (s *State) AddModule(path addrs.ModuleInstance) *ModuleState
- func (s *State) AddModuleState(mod *ModuleState)
- func (s *State) Children(path []string) []*ModuleState
- func (s *State) CompareAges(other *State) (StateAgeComparison, error)
- func (s *State) DeepCopy() *State
- func (s *State) Empty() bool
- func (s *State) EnsureHasLineage()
- func (s *State) Equal(other *State) bool
- func (s *State) FromFutureTerraform() bool
- func (s *State) HasResources() bool
- func (s *State) Init()
- func (s *State) IsRemote() bool
- func (s *State) Lock()
- func (s *State) MarshalEqual(other *State) bool
- func (s *State) ModuleByPath(path addrs.ModuleInstance) *ModuleState
- func (s *State) Remove(addr ...string) error
- func (s *State) RootModule() *ModuleState
- func (s *State) SameLineage(other *State) bool
- func (s *State) String() string
- func (s *State) Unlock()
- func (s *State) Validate() error
- type StateAgeComparison
- type StateFilter
- type StateFilterResult
- type StateFilterResultSlice
- type StateTransformer
- type TargetsTransformer
- type TransitiveReductionTransformer
- type UIInput
- type UIOutput
- type ValueSourceType
- type VertexTransformer
Constants ¶
const (
// StateVersion is the current version for our state file
StateVersion = 3
)
Variables ¶
var ErrNoState = errors.New("no state")
ErrNoState is returned by ReadState when the io.Reader contains no data
var EvalDataForNoInstanceKey = InstanceKeyEvalData{}
EvalDataForNoInstanceKey is a value of InstanceKeyData that sets no instance key values at all, suitable for use in contexts where no keyed instance is relevant.
var GraphTypeMap = map[string]GraphType{ "apply": GraphTypeApply, "plan": GraphTypePlan, "plan-destroy": GraphTypePlanDestroy, "refresh": GraphTypeRefresh, "legacy": GraphTypeLegacy, "validate": GraphTypeValidate, "eval": GraphTypeEval, }
GraphTypeMap is a mapping of human-readable string to GraphType. This is useful to use as the mechanism for human input for configurable graph types.
Functions ¶
func CheckCoreVersionRequirements ¶
func CheckCoreVersionRequirements(config *configs.Config) tfdiags.Diagnostics
CheckCoreVersionRequirements visits each of the modules in the given configuration tree and verifies that any given Core version constraints match with the version of Terraform Core that is being used.
The returned diagnostics will contain errors if any constraints do not match. The returned diagnostics might also return warnings, which should be displayed to the user.
func ConfigTreeDependencies ¶
ConfigTreeDependencies returns the dependencies of the tree of modules described by the given configuration and state.
Both configuration and state are required because there can be resources implied by instances in the state that no longer exist in config.
func ConnectionBlockSupersetSchema ¶
func ConnectionBlockSupersetSchema() *configschema.Block
connectionBlockSupersetSchema is a schema representing the superset of all possible arguments for "connection" blocks across all supported connection types.
This currently lives here because we've not yet updated our communicator subsystem to be aware of schema itself. It's exported only for use in the configs/configupgrade package and should not be used from anywhere else. The caller may not modify any part of the returned schema data structure.
func Eval ¶
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 ¶
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 ¶
GraphDot returns the dot formatting of a visual representation of the given Terraform graph.
func MustShimLegacyState ¶
MustShimLegacyState is a wrapper around ShimLegacyState that panics if the conversion does not succeed. This is primarily intended for tests where the given legacy state is an object constructed within the test.
func ParseResourceIndex ¶
func ParseResourcePath ¶
func PathObjectCacheKey ¶
func PathObjectCacheKey(path addrs.ModuleInstance, objectName string) string
PathObjectCacheKey is like PathCacheKey but includes an additional name to be included in the key, for module-namespaced objects.
The result of this function is guaranteed unique for any distinct pair of path and name, but is not guaranteed to be in any particular format and in particular should never be shown to end-users.
func ProviderHasDataSource ¶
func ProviderHasDataSource(p ResourceProvider, n string) bool
func ProviderHasResource ¶
func ProviderHasResource(p ResourceProvider, n string) bool
func ReadStateV1 ¶
func ReferencesFromConfig ¶
func ReferencesFromConfig(body hcl.Body, schema *configschema.Block) []*addrs.Reference
ReferencesFromConfig returns the references that a configuration has based on the interpolated variables in a configuration.
func ShimLegacyState ¶
ShimLegacyState is a helper that takes the legacy state type and converts it to the new state type.
This is implemented as a state file upgrade, so it will not preserve parts of the state structure that are not included in a serialized state, such as the resolved results of any local values, outputs in non-root modules, etc.
func TestStateFile ¶
TestStateFile writes the given state to the path.
func UpgradeResourceState ¶
func UpgradeResourceState(addr addrs.AbsResourceInstance, provider providers.Interface, src *states.ResourceInstanceObjectSrc, currentSchema *configschema.Block, currentVersion uint64) (*states.ResourceInstanceObjectSrc, tfdiags.Diagnostics)
UpgradeResourceState will, if necessary, run the provider-defined upgrade logic against the given state object to make it compliant with the current schema version. This is a no-op if the given state object is already at the latest version.
If any errors occur during upgrade, error diagnostics are returned. In that case it is not safe to proceed with using the original state object.
Types ¶
type ApplyGraphBuilder ¶
type ApplyGraphBuilder struct { // Config is the configuration tree that the diff was built from. Config *configs.Config // Changes describes the changes that we need apply. Changes *plans.Changes // State is the current state State *states.State // Components is a factory for the plug-in components (providers and // provisioners) available for use. Components contextComponentFactory // Schemas is the repository of schemas we will draw from to analyse // the configuration. Schemas *Schemas // Targets are resources to target. This is only required to make sure // unnecessary outputs aren't included in the apply graph. The plan // builder successfully handles targeting resources. In the future, // outputs should go into the diff so that this is unnecessary. Targets []addrs.Targetable // DisableReduce, if true, will not reduce the graph. Great for testing. DisableReduce bool // Destroy, if true, represents a pure destroy operation Destroy bool // Validate will do structural validation of the graph. Validate bool }
ApplyGraphBuilder implements GraphBuilder and is responsible for building a graph for applying a Terraform diff.
Because the graph is built from the diff (vs. the config or state), this helps ensure that the apply-time graph doesn't modify any resources that aren't explicitly in the diff. There are other scenarios where the diff can be deviated, so this is just one layer of protection.
func (*ApplyGraphBuilder) Build ¶
func (b *ApplyGraphBuilder) Build(path addrs.ModuleInstance) (*Graph, tfdiags.Diagnostics)
See GraphBuilder
func (*ApplyGraphBuilder) Steps ¶
func (b *ApplyGraphBuilder) Steps() []GraphTransformer
See GraphBuilder
type AttachResourceConfigTransformer ¶
type AttachResourceConfigTransformer struct {
Config *configs.Config // Config is the root node in the config tree
}
AttachResourceConfigTransformer goes through the graph and attaches resource configuration structures to nodes that implement GraphNodeAttachManagedResourceConfig or GraphNodeAttachDataResourceConfig.
The attached configuration structures are directly from the configuration. If they're going to be modified, a copy should be made.
func (*AttachResourceConfigTransformer) Transform ¶
func (t *AttachResourceConfigTransformer) Transform(g *Graph) error
type AttachSchemaTransformer ¶
type AttachSchemaTransformer struct {
Schemas *Schemas
}
AttachSchemaTransformer finds nodes that implement GraphNodeAttachResourceSchema, GraphNodeAttachProviderConfigSchema, or GraphNodeAttachProvisionerSchema, looks up the needed schemas for each and then passes them to a method implemented by the node.
func (*AttachSchemaTransformer) Transform ¶
func (t *AttachSchemaTransformer) Transform(g *Graph) error
type AttachStateTransformer ¶
AttachStateTransformer goes through the graph and attaches state to nodes that implement the interfaces above.
func (*AttachStateTransformer) Transform ¶
func (t *AttachStateTransformer) Transform(g *Graph) error
type BackendState ¶
type BackendState struct { Type string `json:"type"` // Backend type ConfigRaw json.RawMessage `json:"config"` // Backend raw config Hash uint64 `json:"hash"` // Hash of portion of configuration from config files }
BackendState stores the configuration to connect to a remote backend.
func (*BackendState) Config ¶
func (s *BackendState) Config(schema *configschema.Block) (cty.Value, error)
Config decodes the type-specific configuration object using the provided schema and returns the result as a cty.Value.
An error is returned if the stored configuration does not conform to the given schema.
func (*BackendState) Empty ¶
func (s *BackendState) Empty() bool
Empty returns true if BackendState has no state.
func (*BackendState) ForPlan ¶
func (s *BackendState) ForPlan(schema *configschema.Block, workspaceName string) (*plans.Backend, error)
ForPlan produces an alternative representation of the reciever that is suitable for storing in a plan. The current workspace must additionally be provided, to be stored alongside the backend configuration.
The backend configuration schema is required in order to properly encode the backend-specific configuration settings.
func (*BackendState) SetConfig ¶
func (s *BackendState) SetConfig(val cty.Value, schema *configschema.Block) error
SetConfig replaces (in-place) the type-specific configuration object using the provided value and associated schema.
An error is returned if the given value does not conform to the implied type of the schema.
type BasicGraphBuilder ¶
type BasicGraphBuilder struct { Steps []GraphTransformer Validate bool // Optional name to add to the graph debug log Name string }
BasicGraphBuilder is a GraphBuilder that builds a graph out of a series of transforms and (optionally) validates the graph is a valid structure.
func (*BasicGraphBuilder) Build ¶
func (b *BasicGraphBuilder) Build(path addrs.ModuleInstance) (*Graph, tfdiags.Diagnostics)
type BuiltinEvalContext ¶
type BuiltinEvalContext struct { // StopContext is the context used to track whether we're complete StopContext context.Context // PathValue is the Path that this context is operating within. PathValue addrs.ModuleInstance // Evaluator is used for evaluating expressions within the scope of this // eval context. Evaluator *Evaluator // Schemas is a repository of all of the schemas we should need to // decode configuration blocks and expressions. This must be constructed by // the caller to include schemas for all of the providers, resource types, // data sources and provisioners used by the given configuration and // state. // // This must not be mutated during evaluation. Schemas *Schemas // VariableValues contains the variable values across all modules. This // structure is shared across the entire containing context, and so it // may be accessed only when holding VariableValuesLock. // The keys of the first level of VariableValues are the string // representations of addrs.ModuleInstance values. The second-level keys // are variable names within each module instance. VariableValues map[string]map[string]cty.Value VariableValuesLock *sync.Mutex Components contextComponentFactory Hooks []Hook InputValue UIInput ProviderCache map[string]providers.Interface ProviderInputConfig map[string]map[string]cty.Value ProviderLock *sync.Mutex ProvisionerCache map[string]provisioners.Interface ProvisionerLock *sync.Mutex ChangesValue *plans.ChangesSync StateValue *states.SyncState // contains filtered or unexported fields }
BuiltinEvalContext is an EvalContext implementation that is used by Terraform by default.
func (*BuiltinEvalContext) Changes ¶
func (ctx *BuiltinEvalContext) Changes() *plans.ChangesSync
func (*BuiltinEvalContext) CloseProvider ¶
func (ctx *BuiltinEvalContext) CloseProvider(addr addrs.ProviderConfig) error
func (*BuiltinEvalContext) CloseProvisioner ¶
func (ctx *BuiltinEvalContext) CloseProvisioner(n string) error
func (*BuiltinEvalContext) ConfigureProvider ¶
func (ctx *BuiltinEvalContext) ConfigureProvider(addr addrs.ProviderConfig, cfg cty.Value) tfdiags.Diagnostics
func (*BuiltinEvalContext) EvaluateBlock ¶
func (ctx *BuiltinEvalContext) EvaluateBlock(body hcl.Body, schema *configschema.Block, self addrs.Referenceable, keyData InstanceKeyEvalData) (cty.Value, hcl.Body, tfdiags.Diagnostics)
func (*BuiltinEvalContext) EvaluateExpr ¶
func (ctx *BuiltinEvalContext) EvaluateExpr(expr hcl.Expression, wantType cty.Type, self addrs.Referenceable) (cty.Value, tfdiags.Diagnostics)
func (*BuiltinEvalContext) EvaluationScope ¶
func (ctx *BuiltinEvalContext) EvaluationScope(self addrs.Referenceable, keyData InstanceKeyEvalData) *lang.Scope
func (*BuiltinEvalContext) Hook ¶
func (ctx *BuiltinEvalContext) Hook(fn func(Hook) (HookAction, error)) error
func (*BuiltinEvalContext) InitProvider ¶
func (ctx *BuiltinEvalContext) InitProvider(typeName string, addr addrs.ProviderConfig) (providers.Interface, error)
func (*BuiltinEvalContext) InitProvisioner ¶
func (ctx *BuiltinEvalContext) InitProvisioner(n string) (provisioners.Interface, error)
func (*BuiltinEvalContext) Input ¶
func (ctx *BuiltinEvalContext) Input() UIInput
func (*BuiltinEvalContext) Path ¶
func (ctx *BuiltinEvalContext) Path() addrs.ModuleInstance
func (*BuiltinEvalContext) Provider ¶
func (ctx *BuiltinEvalContext) Provider(addr addrs.AbsProviderConfig) providers.Interface
func (*BuiltinEvalContext) ProviderInput ¶
func (ctx *BuiltinEvalContext) ProviderInput(pc addrs.ProviderConfig) map[string]cty.Value
func (*BuiltinEvalContext) ProviderSchema ¶
func (ctx *BuiltinEvalContext) ProviderSchema(addr addrs.AbsProviderConfig) *ProviderSchema
func (*BuiltinEvalContext) Provisioner ¶
func (ctx *BuiltinEvalContext) Provisioner(n string) provisioners.Interface
func (*BuiltinEvalContext) ProvisionerSchema ¶
func (ctx *BuiltinEvalContext) ProvisionerSchema(n string) *configschema.Block
func (*BuiltinEvalContext) SetModuleCallArguments ¶
func (ctx *BuiltinEvalContext) SetModuleCallArguments(n addrs.ModuleCallInstance, vals map[string]cty.Value)
func (*BuiltinEvalContext) SetProviderInput ¶
func (ctx *BuiltinEvalContext) SetProviderInput(pc addrs.ProviderConfig, c map[string]cty.Value)
func (*BuiltinEvalContext) State ¶
func (ctx *BuiltinEvalContext) State() *states.SyncState
func (*BuiltinEvalContext) Stopped ¶
func (ctx *BuiltinEvalContext) Stopped() <-chan struct{}
type CBDEdgeTransformer ¶
type CBDEdgeTransformer struct { // Module and State are only needed to look up dependencies in // any way possible. Either can be nil if not availabile. Config *configs.Config State *states.State // If configuration is present then Schemas is required in order to // obtain schema information from providers and provisioners so we can // properly resolve implicit dependencies. Schemas *Schemas // If the operation is a simple destroy, no transformation is done. Destroy bool }
CBDEdgeTransformer modifies the edges of CBD nodes that went through the DestroyEdgeTransformer to have the right dependencies. There are two real tasks here:
With CBD, the destroy edge is inverted: the destroy depends on the creation.
A_d must depend on resources that depend on A. This is to enable the destroy to only happen once nodes that depend on A successfully update to A. Example: adding a web server updates the load balancer before deleting the old web server.
This transformer requires that a previous transformer has already forced create_before_destroy on for nodes that are depended on by explicit CBD nodes. This is the logic in ForcedCBDTransformer, though in practice we will get here by recording the CBD-ness of each change in the plan during the plan walk and then forcing the nodes into the appropriate setting during DiffTransformer when building the apply graph.
func (*CBDEdgeTransformer) Transform ¶
func (t *CBDEdgeTransformer) Transform(g *Graph) error
type CallbackUIOutput ¶
type CallbackUIOutput struct {
OutputFn func(string)
}
func (*CallbackUIOutput) Output ¶
func (o *CallbackUIOutput) Output(v string)
type CloseProviderTransformer ¶
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 ¶
func (t *CloseProviderTransformer) Transform(g *Graph) error
type CloseProvisionerTransformer ¶
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 ¶
func (t *CloseProvisionerTransformer) Transform(g *Graph) error
type ConcreteProviderNodeFunc ¶
type ConcreteProviderNodeFunc func(*NodeAbstractProvider) dag.Vertex
ConcreteProviderNodeFunc is a callback type used to convert an abstract provider to a concrete one of some type.
type ConcreteResourceInstanceDeposedNodeFunc ¶
type ConcreteResourceInstanceDeposedNodeFunc func(*NodeAbstractResourceInstance, states.DeposedKey) dag.Vertex
ConcreteResourceInstanceDeposedNodeFunc is a callback type used to convert an abstract resource instance to a concrete one of some type that has an associated deposed object key.
type ConcreteResourceInstanceNodeFunc ¶
type ConcreteResourceInstanceNodeFunc func(*NodeAbstractResourceInstance) dag.Vertex
ConcreteResourceInstanceNodeFunc is a callback type used to convert an abstract resource instance to a concrete one of some type.
type ConcreteResourceNodeFunc ¶
type ConcreteResourceNodeFunc func(*NodeAbstractResource) dag.Vertex
ConcreteResourceNodeFunc is a callback type used to convert an abstract resource to a concrete one of some type.
type ConfigTransformer ¶
type ConfigTransformer struct { Concrete ConcreteResourceNodeFunc // Module is the module to add resources from. Config *configs.Config // Unique will only add resources that aren't already present in the graph. Unique bool // Mode will only add resources that match the given mode ModeFilter bool Mode addrs.ResourceMode // contains filtered or unexported fields }
ConfigTransformer is a GraphTransformer that adds all the resources from the configuration to the graph.
The module used to configure this transformer must be the root module.
Only resources are added to the graph. Variables, outputs, and providers must be added via other transforms.
Unlike ConfigTransformerOld, this transformer creates a graph with all resources including module resources, rather than creating module nodes that are then "flattened".
func (*ConfigTransformer) Transform ¶
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.
func NewContext ¶
func NewContext(opts *ContextOpts) (*Context, tfdiags.Diagnostics)
NewContext creates a new Context structure.
Once a Context is created, the caller must not access or mutate any of the objects referenced (directly or indirectly) by the ContextOpts fields.
If the returned diagnostics contains errors then the resulting context is invalid and must not be used.
func (*Context) Apply ¶
func (c *Context) Apply() (*states.State, tfdiags.Diagnostics)
Apply applies the changes represented by this context and returns the resulting state.
Even in the case an error is returned, the state may be returned and will potentially be partially updated. In addition to returning the resulting state, this context is updated with the latest state.
If the state is required after an error, the caller should call Context.State, rather than rely on the return value.
TODO: Apply and Refresh should either always return a state, or rely on the
State() method. Currently the helper/resource testing framework relies on the absence of a returned state to determine if Destroy can be called, so that will need to be refactored before this can be changed.
func (*Context) Eval ¶
func (c *Context) Eval(path addrs.ModuleInstance) (*lang.Scope, tfdiags.Diagnostics)
Eval produces a scope in which expressions can be evaluated for the given module path.
This method must first evaluate any ephemeral values (input variables, local values, and output values) in the configuration. These ephemeral values are not included in the persisted state, so they must be re-computed using other values in the state before they can be properly evaluated. The updated values are retained in the main state associated with the receiving context.
This function takes no action against remote APIs but it does need access to all provider and provisioner instances in order to obtain their schemas for type checking.
The result is an evaluation scope that can be used to resolve references against the root module. If the returned diagnostics contains errors then the returned scope may be nil. If it is not nil then it may still be used to attempt expression evaluation or other analysis, but some expressions may not behave as expected.
func (*Context) Graph ¶
func (c *Context) Graph(typ GraphType, opts *ContextGraphOpts) (*Graph, tfdiags.Diagnostics)
Graph returns the graph used for the given operation type.
The most extensive or complex graph type is GraphTypePlan.
func (*Context) Import ¶
func (c *Context) Import(opts *ImportOpts) (*states.State, tfdiags.Diagnostics)
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 ¶
func (c *Context) Input(mode InputMode) tfdiags.Diagnostics
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) Plan ¶
func (c *Context) Plan() (*plans.Plan, tfdiags.Diagnostics)
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() (*states.State, tfdiags.Diagnostics)
Refresh goes through all the resources in the state and refreshes them to their latest state. This will update the state that this context works with, along with returning it.
Even in the case an error is returned, the state may be returned and will potentially be partially updated.
func (*Context) SetVariable ¶
SetVariable sets a variable after a context has already been built.
func (*Context) ShadowError ¶
ShadowError returns any errors caught during a shadow operation.
A shadow operation is an operation run in parallel to a real operation that performs the same tasks using new logic on copied state. The results are compared to ensure that the new logic works the same as the old logic. The shadow never affects the real operation or return values.
The result of the shadow operation are only available through this function call after a real operation is complete.
For API consumers of Context, you can safely ignore this function completely if you have no interest in helping report experimental feature errors to Terraform maintainers. Otherwise, please call this function after every operation and report this to the user.
IMPORTANT: Shadow errors are _never_ critical: they _never_ affect the real state or result of a real operation. They are purely informational to assist in future Terraform versions being more stable. Please message this effectively to the end user.
This must be called only when no other operation is running (refresh, plan, etc.). The result can be used in parallel to any other operation running.
func (*Context) State ¶
State returns a copy of the current state associated with this context.
This cannot safely be called in parallel with any other Context function.
func (*Context) Stop ¶
func (c *Context) Stop()
Stop stops the running task.
Stop will block until the task completes.
func (*Context) Validate ¶
func (c *Context) Validate() tfdiags.Diagnostics
Validate performs semantic validation of the configuration, and returning any warnings or errors.
Syntax and structural checks are performed by the configuration loader, and so are not repeated here.
func (*Context) Variables ¶
func (c *Context) Variables() InputValues
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 ¶
type ContextGraphWalker ¶
type ContextGraphWalker struct { NullGraphWalker // Configurable values Context *Context State *states.SyncState // Used for safe concurrent access to state Changes *plans.ChangesSync // Used for safe concurrent writes to changes Operation walkOperation StopContext context.Context RootVariableValues InputValues // This is an output. Do not set this, nor read it while a graph walk // is in progress. NonFatalDiagnostics tfdiags.Diagnostics // contains filtered or unexported fields }
ContextGraphWalker is the GraphWalker implementation used with the Context struct to walk and evaluate the graph.
func (*ContextGraphWalker) EnterEvalTree ¶
func (w *ContextGraphWalker) EnterEvalTree(v dag.Vertex, n EvalNode) EvalNode
func (*ContextGraphWalker) EnterPath ¶
func (w *ContextGraphWalker) EnterPath(path addrs.ModuleInstance) EvalContext
func (*ContextGraphWalker) ExitEvalTree ¶
func (w *ContextGraphWalker) ExitEvalTree(v dag.Vertex, output interface{}, err error) tfdiags.Diagnostics
type ContextMeta ¶
type ContextMeta struct {
Env string // Env is the state environment
}
ContextMeta is metadata about the running context. This is information that this package or structure cannot determine on its own but exposes into Terraform in various ways. This must be provided by the Context initializer.
type ContextOpts ¶
type ContextOpts struct { Config *configs.Config Changes *plans.Changes State *states.State Targets []addrs.Targetable Variables InputValues Meta *ContextMeta Destroy bool Hooks []Hook Parallelism int ProviderResolver providers.Resolver Provisioners map[string]ProvisionerFactory // If non-nil, will apply as additional constraints on the provider // plugins that will be requested from the provider resolver. ProviderSHA256s map[string][]byte SkipProviderVerify bool UIInput UIInput }
ContextOpts are the user-configurable options to create a context with NewContext.
type CountBoundaryTransformer ¶
CountBoundaryTransformer adds a node that depends on everything else so that it runs last in order to clean up the state for nodes that are on the "count boundary": "foo.0" when only one exists becomes "foo"
func (*CountBoundaryTransformer) Transform ¶
func (t *CountBoundaryTransformer) Transform(g *Graph) error
type DataSource ¶
type DataSource struct { Name string // SchemaAvailable is set if the provider supports the ProviderSchema, // ResourceTypeSchema and DataSourceSchema methods. Although it is // included on each resource type, it's actually a provider-wide setting // that's smuggled here only because that avoids a breaking change to // the plugin protocol. SchemaAvailable bool }
DataSource is a data source that a resource provider implements.
type DestroyEdge ¶
DestroyEdge is an edge that represents a standard "destroy" relationship: Target depends on Source because Source is destroying.
func (*DestroyEdge) Hashcode ¶
func (e *DestroyEdge) Hashcode() interface{}
func (*DestroyEdge) Source ¶
func (e *DestroyEdge) Source() dag.Vertex
func (*DestroyEdge) Target ¶
func (e *DestroyEdge) Target() dag.Vertex
type DestroyEdgeTransformer ¶
type DestroyEdgeTransformer struct { // These are needed to properly build the graph of dependencies // to determine what a destroy node depends on. Any of these can be nil. Config *configs.Config State *states.State // If configuration is present then Schemas is required in order to // obtain schema information from providers and provisioners in order // to properly resolve implicit dependencies. Schemas *Schemas }
DestroyEdgeTransformer is a GraphTransformer that creates the proper references for destroy resources. Destroy resources are more complex in that they must be depend on the destruction of resources that in turn depend on the CREATION of the node being destroy.
That is complicated. Visually:
B_d -> A_d -> A -> B
Notice that A destroy depends on B destroy, while B create depends on A create. They're inverted. This must be done for example because often dependent resources will block parent resources from deleting. Concrete example: VPC with subnets, the VPC can't be deleted while there are still subnets.
func (*DestroyEdgeTransformer) Transform ¶
func (t *DestroyEdgeTransformer) Transform(g *Graph) error
type DestroyOutputTransformer ¶
type DestroyOutputTransformer struct { }
DestroyOutputTransformer is a GraphTransformer that adds nodes to delete outputs during destroy. We need to do this to ensure that no stale outputs are ever left in the state.
func (*DestroyOutputTransformer) Transform ¶
func (t *DestroyOutputTransformer) Transform(g *Graph) error
type DestroyPlanGraphBuilder ¶
type DestroyPlanGraphBuilder struct { // Config is the configuration tree to build the plan from. Config *configs.Config // State is the current state State *states.State // Components is a factory for the plug-in components (providers and // provisioners) available for use. Components contextComponentFactory // Schemas is the repository of schemas we will draw from to analyse // the configuration. Schemas *Schemas // Targets are resources to target Targets []addrs.Targetable // Validate will do structural validation of the graph. Validate bool }
DestroyPlanGraphBuilder implements GraphBuilder and is responsible for planning a pure-destroy.
Planning a pure destroy operation is simple because we can ignore most ordering configuration and simply reverse the state.
func (*DestroyPlanGraphBuilder) Build ¶
func (b *DestroyPlanGraphBuilder) Build(path addrs.ModuleInstance) (*Graph, tfdiags.Diagnostics)
See GraphBuilder
func (*DestroyPlanGraphBuilder) Steps ¶
func (b *DestroyPlanGraphBuilder) Steps() []GraphTransformer
See GraphBuilder
type DestroyValueReferenceTransformer ¶
type DestroyValueReferenceTransformer struct{}
DestroyReferenceTransformer is a GraphTransformer that reverses the edges for locals and outputs that depend on other nodes which will be removed during destroy. If a destroy node is evaluated before the local or output value, it will be removed from the state, and the later interpolation will fail.
func (*DestroyValueReferenceTransformer) Transform ¶
func (t *DestroyValueReferenceTransformer) Transform(g *Graph) error
type Diff ¶
type Diff struct { // Modules contains all the modules that have a diff Modules []*ModuleDiff }
Diff tracks the changes that are necessary to apply a configuration to an existing infrastructure.
func (*Diff) AddModule ¶
func (d *Diff) AddModule(path addrs.ModuleInstance) *ModuleDiff
AddModule adds the module with the given path to the diff.
This should be the preferred method to add module diffs since it allows us to optimize lookups later as well as control sorting.
func (*Diff) DeepCopy ¶
DeepCopy performs a deep copy of all parts of the Diff, making the resulting Diff safe to use without modifying this one.
func (*Diff) Equal ¶
Equal compares two diffs for exact equality.
This is different from the Same comparison that is supported which checks for operation equality taking into account computed values. Equal instead checks for exact equality.
func (*Diff) ModuleByPath ¶
func (d *Diff) ModuleByPath(path addrs.ModuleInstance) *ModuleDiff
ModuleByPath is used to lookup the module diff for the given path. This should be the preferred lookup mechanism as it allows for future lookup optimizations.
func (*Diff) Prune ¶
func (d *Diff) Prune()
Prune cleans out unused structures in the diff without affecting the behavior of the diff at all.
This is not safe to call concurrently. This is safe to call on a nil Diff.
func (*Diff) RootModule ¶
func (d *Diff) RootModule() *ModuleDiff
RootModule returns the ModuleState for the root module
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 ¶
type DiffChangeType byte
DiffChangeType is an enum with the kind of changes a diff has planned.
const ( DiffInvalid DiffChangeType = iota DiffNone DiffCreate DiffUpdate DiffDestroy DiffDestroyCreate // DiffRefresh is only used in the UI for displaying diffs. // Managed resource reads never appear in plan, and when data source // reads appear they are represented as DiffCreate in core before // transforming to DiffRefresh in the UI layer. DiffRefresh // TODO: Actually use DiffRefresh in core too, for less confusion )
type DiffTransformer ¶
type DiffTransformer struct { Concrete ConcreteResourceInstanceNodeFunc State *states.State Changes *plans.Changes }
DiffTransformer is a GraphTransformer that adds graph nodes representing each of the resource changes described in the given Changes object.
func (*DiffTransformer) Transform ¶
func (t *DiffTransformer) Transform(g *Graph) error
type EphemeralState ¶
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 ¶
type EvalApply struct { Addr addrs.ResourceInstance Config *configs.Resource Dependencies []addrs.Referenceable State **states.ResourceInstanceObject Change **plans.ResourceInstanceChange ProviderAddr addrs.AbsProviderConfig Provider *providers.Interface ProviderSchema **ProviderSchema Output **states.ResourceInstanceObject CreateNew *bool Error *error }
EvalApply is an EvalNode implementation that writes the diff to the full diff.
type EvalApplyPost ¶
type EvalApplyPost struct { Addr addrs.ResourceInstance Gen states.Generation State **states.ResourceInstanceObject Error *error }
EvalApplyPost is an EvalNode implementation that does the post-Apply work
func (*EvalApplyPost) Eval ¶
func (n *EvalApplyPost) Eval(ctx EvalContext) (interface{}, error)
TODO: test
type EvalApplyPre ¶
type EvalApplyPre struct { Addr addrs.ResourceInstance Gen states.Generation State **states.ResourceInstanceObject Change **plans.ResourceInstanceChange }
EvalApplyPre is an EvalNode implementation that does the pre-Apply work
func (*EvalApplyPre) Eval ¶
func (n *EvalApplyPre) Eval(ctx EvalContext) (interface{}, error)
TODO: test
type EvalApplyProvisioners ¶
type EvalApplyProvisioners struct { Addr addrs.ResourceInstance State **states.ResourceInstanceObject ResourceConfig *configs.Resource CreateNew *bool Error *error // When is the type of provisioner to run at this point When configs.ProvisionerWhen }
EvalApplyProvisioners is an EvalNode implementation that executes the provisioners for a resource.
TODO(mitchellh): This should probably be split up into a more fine-grained ApplyProvisioner (single) that is looped over.
func (*EvalApplyProvisioners) Eval ¶
func (n *EvalApplyProvisioners) Eval(ctx EvalContext) (interface{}, error)
TODO: test
type EvalCheckModuleRemoved ¶
type EvalCheckModuleRemoved struct {
Addr addrs.ModuleInstance
}
EvalCheckModuleRemoved is an EvalNode implementation that verifies that a module has been removed from the state as expected.
func (*EvalCheckModuleRemoved) Eval ¶
func (n *EvalCheckModuleRemoved) Eval(ctx EvalContext) (interface{}, error)
type EvalCheckPlannedChange ¶
type EvalCheckPlannedChange struct { Addr addrs.ResourceInstance ProviderAddr addrs.AbsProviderConfig ProviderSchema **ProviderSchema // We take ResourceInstanceChange objects here just because that's what's // convenient to pass in from the evaltree implementation, but we really // only look at the "After" value of each change. Planned, Actual **plans.ResourceInstanceChange }
EvalCheckPlannedChange is an EvalNode implementation that produces errors if the _actual_ expected value is not compatible with what was recorded in the plan.
Errors here are most often indicative of a bug in the provider, so our error messages will report with that in mind. It's also possible that there's a bug in Terraform's Core's own "proposed new value" code in EvalDiff.
func (*EvalCheckPlannedChange) Eval ¶
func (n *EvalCheckPlannedChange) Eval(ctx EvalContext) (interface{}, error)
type EvalCheckPreventDestroy ¶
type EvalCheckPreventDestroy struct { Addr addrs.ResourceInstance Config *configs.Resource Change **plans.ResourceInstanceChange }
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 ¶
func (n *EvalCheckPreventDestroy) Eval(ctx EvalContext) (interface{}, error)
type EvalCloseProvider ¶
type EvalCloseProvider struct {
Addr addrs.ProviderConfig
}
EvalCloseProvider is an EvalNode implementation that closes provider connections that aren't needed anymore.
func (*EvalCloseProvider) Eval ¶
func (n *EvalCloseProvider) Eval(ctx EvalContext) (interface{}, error)
type EvalCloseProvisioner ¶
type EvalCloseProvisioner struct {
Name string
}
EvalCloseProvisioner is an EvalNode implementation that closes provisioner connections that aren't needed anymore.
func (*EvalCloseProvisioner) Eval ¶
func (n *EvalCloseProvisioner) Eval(ctx EvalContext) (interface{}, error)
type EvalConfigBlock ¶
type EvalConfigBlock struct { Config *hcl.Body Schema *configschema.Block SelfAddr addrs.Referenceable Output *cty.Value ExpandedConfig *hcl.Body ContinueOnErr bool }
EvalConfigBlock is an EvalNode implementation that takes a raw configuration block and evaluates any expressions within it.
ExpandedConfig is populated with the result of expanding any "dynamic" blocks in the given body, which can be useful for extracting correct source location information for specific attributes in the result.
func (*EvalConfigBlock) Eval ¶
func (n *EvalConfigBlock) Eval(ctx EvalContext) (interface{}, error)
type EvalConfigExpr ¶
type EvalConfigExpr struct { Expr hcl.Expression SelfAddr addrs.Referenceable Output *cty.Value }
EvalConfigExpr is an EvalNode implementation that takes a raw configuration expression and evaluates it.
func (*EvalConfigExpr) Eval ¶
func (n *EvalConfigExpr) Eval(ctx EvalContext) (interface{}, error)
type EvalConfigProvider ¶
type EvalConfigProvider struct { Addr addrs.ProviderConfig Provider *providers.Interface Config *configs.Provider }
EvalConfigProvider is an EvalNode implementation that configures a provider that is already initialized and retrieved.
func (*EvalConfigProvider) Eval ¶
func (n *EvalConfigProvider) Eval(ctx EvalContext) (interface{}, error)
type EvalContext ¶
type EvalContext interface { // Stopped returns a channel that is closed when evaluation is stopped // via Terraform.Context.Stop() Stopped() <-chan struct{} // Path is the current module path. Path() addrs.ModuleInstance // Hook is used to call hook methods. The callback is called for each // hook and should return the hook action to take and the error. Hook(func(Hook) (HookAction, error)) error // Input is the UIInput object for interacting with the UI. Input() UIInput // InitProvider initializes the provider with the given type and address, and // returns the implementation of the resource provider or an error. // // It is an error to initialize the same provider more than once. InitProvider(typ string, addr addrs.ProviderConfig) (providers.Interface, error) // Provider gets the provider instance with the given address (already // initialized) or returns nil if the provider isn't initialized. // // This method expects an _absolute_ provider configuration address, since // resources in one module are able to use providers from other modules. // InitProvider must've been called on the EvalContext of the module // that owns the given provider before calling this method. Provider(addrs.AbsProviderConfig) providers.Interface // ProviderSchema retrieves the schema for a particular provider, which // must have already been initialized with InitProvider. // // This method expects an _absolute_ provider configuration address, since // resources in one module are able to use providers from other modules. ProviderSchema(addrs.AbsProviderConfig) *ProviderSchema // CloseProvider closes provider connections that aren't needed anymore. CloseProvider(addrs.ProviderConfig) 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(addrs.ProviderConfig, cty.Value) tfdiags.Diagnostics // ProviderInput and SetProviderInput are used to configure providers // from user input. ProviderInput(addrs.ProviderConfig) map[string]cty.Value SetProviderInput(addrs.ProviderConfig, map[string]cty.Value) // 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) (provisioners.Interface, error) // Provisioner gets the provisioner instance with the given name (already // initialized) or returns nil if the provisioner isn't initialized. Provisioner(string) provisioners.Interface // ProvisionerSchema retrieves the main configuration schema for a // particular provisioner, which must have already been initialized with // InitProvisioner. ProvisionerSchema(string) *configschema.Block // CloseProvisioner closes provisioner connections that aren't needed // anymore. CloseProvisioner(string) error // EvaluateBlock takes the given raw configuration block and associated // schema and evaluates it to produce a value of an object type that // conforms to the implied type of the schema. // // The "self" argument is optional. If given, it is the referenceable // address that the name "self" should behave as an alias for when // evaluating. Set this to nil if the "self" object should not be available. // // The "key" argument is also optional. If given, it is the instance key // of the current object within the multi-instance container it belongs // to. For example, on a resource block with "count" set this should be // set to a different addrs.IntKey for each instance created from that // block. Set this to addrs.NoKey if not appropriate. // // The returned body is an expanded version of the given body, with any // "dynamic" blocks replaced with zero or more static blocks. This can be // used to extract correct source location information about attributes of // the returned object value. EvaluateBlock(body hcl.Body, schema *configschema.Block, self addrs.Referenceable, keyData InstanceKeyEvalData) (cty.Value, hcl.Body, tfdiags.Diagnostics) // EvaluateExpr takes the given HCL expression and evaluates it to produce // a value. // // The "self" argument is optional. If given, it is the referenceable // address that the name "self" should behave as an alias for when // evaluating. Set this to nil if the "self" object should not be available. EvaluateExpr(expr hcl.Expression, wantType cty.Type, self addrs.Referenceable) (cty.Value, tfdiags.Diagnostics) // EvaluationScope returns a scope that can be used to evaluate reference // addresses in this context. EvaluationScope(self addrs.Referenceable, keyData InstanceKeyEvalData) *lang.Scope // SetModuleCallArguments defines values for the variables of a particular // child module call. // // Calling this function multiple times has merging behavior, keeping any // previously-set keys that are not present in the new map. SetModuleCallArguments(addrs.ModuleCallInstance, map[string]cty.Value) // Changes returns the writer object that can be used to write new proposed // changes into the global changes set. Changes() *plans.ChangesSync // State returns a wrapper object that provides safe concurrent access to // the global state. State() *states.SyncState }
EvalContext is the interface that is given to eval nodes to execute.
type EvalCountFixZeroOneBoundaryGlobal ¶
EvalCountFixZeroOneBoundaryGlobal is an EvalNode that fixes up the state when there is a resource count with zero/one boundary, i.e. fixing a resource named "aws_instance.foo" to "aws_instance.foo.0" and vice-versa.
This works on the global state.
func (*EvalCountFixZeroOneBoundaryGlobal) Eval ¶
func (n *EvalCountFixZeroOneBoundaryGlobal) Eval(ctx EvalContext) (interface{}, error)
TODO: test
type EvalDeleteLocal ¶
type EvalDeleteLocal struct {
Addr addrs.LocalValue
}
EvalDeleteLocal is an EvalNode implementation that deletes a Local value from the state. Locals aren't persisted, but we don't need to evaluate them during destroy.
func (*EvalDeleteLocal) Eval ¶
func (n *EvalDeleteLocal) Eval(ctx EvalContext) (interface{}, error)
type EvalDeleteOutput ¶
type EvalDeleteOutput struct {
Addr addrs.OutputValue
}
EvalDeleteOutput is an EvalNode implementation that deletes an output from the state.
func (*EvalDeleteOutput) Eval ¶
func (n *EvalDeleteOutput) Eval(ctx EvalContext) (interface{}, error)
TODO: test
type EvalDeposeState ¶
type EvalDeposeState struct { Addr addrs.ResourceInstance // ForceKey, if a value other than states.NotDeposed, will be used as the // key for the newly-created deposed object that results from this action. // If set to states.NotDeposed (the zero value), a new unique key will be // allocated. ForceKey states.DeposedKey // OutputKey, if non-nil, will be written with the deposed object key that // was generated for the object. This can then be passed to // EvalUndeposeState.Key so it knows which deposed instance to forget. OutputKey *states.DeposedKey }
EvalDeposeState is an EvalNode implementation that moves the current object for the given instance to instead be a deposed object, leaving the instance with no current object. This is used at the beginning of a create-before-destroy replace action so that the create can create while preserving the old state of the to-be-destroyed object.
func (*EvalDeposeState) Eval ¶
func (n *EvalDeposeState) Eval(ctx EvalContext) (interface{}, error)
TODO: test
type EvalDiff ¶
type EvalDiff struct { Addr addrs.ResourceInstance Config *configs.Resource Provider *providers.Interface ProviderAddr addrs.AbsProviderConfig ProviderSchema **ProviderSchema State **states.ResourceInstanceObject PreviousDiff **plans.ResourceInstanceChange // CreateBeforeDestroy is set if either the resource's own config sets // create_before_destroy explicitly or if dependencies have forced the // resource to be handled as create_before_destroy in order to avoid // a dependency cycle. CreateBeforeDestroy bool OutputChange **plans.ResourceInstanceChange OutputValue *cty.Value OutputState **states.ResourceInstanceObject Stub bool }
EvalDiff is an EvalNode implementation that detects changes for a given resource instance.
type EvalDiffDestroy ¶
type EvalDiffDestroy struct { Addr addrs.ResourceInstance DeposedKey states.DeposedKey State **states.ResourceInstanceObject ProviderAddr addrs.AbsProviderConfig Output **plans.ResourceInstanceChange OutputState **states.ResourceInstanceObject }
EvalDiffDestroy is an EvalNode implementation that returns a plain destroy diff.
func (*EvalDiffDestroy) Eval ¶
func (n *EvalDiffDestroy) Eval(ctx EvalContext) (interface{}, error)
TODO: test
type EvalEarlyExitError ¶
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 ¶
func (EvalEarlyExitError) Error() string
type EvalForgetResourceState ¶
EvalForgetResourceState is an EvalNode implementation that prunes out an empty resource-level state for a given resource address, or produces an error if it isn't empty after all.
This should be the last action taken for a resource that has been removed from the configuration altogether, to clean up the leftover husk of the resource in the state after other EvalNodes have destroyed and removed all of the instances and instance objects beneath it.
func (*EvalForgetResourceState) Eval ¶
func (n *EvalForgetResourceState) Eval(ctx EvalContext) (interface{}, error)
type EvalGetProvider ¶
type EvalGetProvider struct { Addr addrs.AbsProviderConfig Output *providers.Interface // If non-nil, Schema will be updated after eval to refer to the // schema of the provider. Schema **ProviderSchema }
EvalGetProvider is an EvalNode implementation that retrieves an already initialized provider instance for the given name.
Unlike most eval nodes, this takes an _absolute_ provider configuration, because providers can be passed into and inherited between modules. Resource nodes must therefore know the absolute path of the provider they will use, which is usually accomplished by implementing interface GraphNodeProviderConsumer.
func (*EvalGetProvider) Eval ¶
func (n *EvalGetProvider) Eval(ctx EvalContext) (interface{}, error)
type EvalGetProvisioner ¶
type EvalGetProvisioner struct { Name string Output *provisioners.Interface Schema **configschema.Block }
EvalGetProvisioner is an EvalNode implementation that retrieves an already initialized provisioner instance for the given name.
func (*EvalGetProvisioner) Eval ¶
func (n *EvalGetProvisioner) Eval(ctx EvalContext) (interface{}, error)
type EvalGraphBuilder ¶
type EvalGraphBuilder struct { // Config is the configuration tree. Config *configs.Config // State is the current state State *states.State // Components is a factory for the plug-in components (providers and // provisioners) available for use. Components contextComponentFactory // Schemas is the repository of schemas we will draw from to analyse // the configuration. Schemas *Schemas }
EvalGraphBuilder implements GraphBuilder and constructs a graph suitable for evaluating in-memory values (input variables, local values, output values) in the state without any other side-effects.
This graph is used only in weird cases, such as the "terraform console" CLI command, where we need to evaluate expressions against the state without taking any other actions.
The generated graph will include nodes for providers, resources, etc just to allow indirect dependencies to be resolved, but these nodes will not take any actions themselves since we assume that their parts of the state, if any, are already complete.
Although the providers are never configured, they must still be available in order to obtain schema information used for type checking, etc.
func (*EvalGraphBuilder) Build ¶
func (b *EvalGraphBuilder) Build(path addrs.ModuleInstance) (*Graph, tfdiags.Diagnostics)
See GraphBuilder
func (*EvalGraphBuilder) Steps ¶
func (b *EvalGraphBuilder) Steps() []GraphTransformer
See GraphBuilder
type EvalIf ¶
type EvalIf struct { If func(EvalContext) (bool, error) Then EvalNode Else EvalNode }
EvalIf is an EvalNode that is a conditional.
type EvalImportState ¶
type EvalImportState struct { Addr addrs.ResourceInstance Provider *providers.Interface ID string Output *[]providers.ImportedResource }
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 { Addr addrs.ResourceInstance State **states.ResourceInstanceObject }
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 ¶
type EvalInitProvider struct { TypeName string Addr addrs.ProviderConfig }
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 ¶
func (n *EvalInitProvider) Eval(ctx EvalContext) (interface{}, error)
type EvalInitProvisioner ¶
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 ¶
func (n *EvalInitProvisioner) Eval(ctx EvalContext) (interface{}, error)
type EvalLocal ¶
type EvalLocal struct { Addr addrs.LocalValue Expr hcl.Expression }
EvalLocal is an EvalNode implementation that evaluates the expression for a local value and writes it into a transient part of the state.
func (*EvalLocal) Eval ¶
func (n *EvalLocal) Eval(ctx EvalContext) (interface{}, error)
type EvalMaybeRestoreDeposedObject ¶
type EvalMaybeRestoreDeposedObject struct { Addr addrs.ResourceInstance // Key is a pointer to the deposed object key that should be forgotten // from the state, which must be non-nil. Key *states.DeposedKey }
EvalMaybeRestoreDeposedObject is an EvalNode implementation that will restore a particular deposed object of the specified resource instance to be the "current" object if and only if the instance doesn't currently have a current object.
This is intended for use when the create leg of a create before destroy fails with no partial new object: if we didn't take any action, the user would be left in the unfortunate situation of having no current object and the previously-workign object now deposed. This EvalNode causes a better outcome by restoring things to how they were before the replace operation began.
The create operation may have produced a partial result even though it failed and it's important that we don't "forget" that state, so in that situation the prior object remains deposed and the partial new object remains the current object, allowing the situation to hopefully be improved in a subsequent run.
func (*EvalMaybeRestoreDeposedObject) Eval ¶
func (n *EvalMaybeRestoreDeposedObject) Eval(ctx EvalContext) (interface{}, error)
TODO: test
type EvalMaybeTainted ¶
type EvalMaybeTainted struct { Addr addrs.ResourceInstance Gen states.Generation Change **plans.ResourceInstanceChange State **states.ResourceInstanceObject Error *error // If StateOutput is not nil, its referent will be assigned either the same // pointer as State or a new object with its status set as Tainted, // depending on whether an error is given and if this was a create action. StateOutput **states.ResourceInstanceObject }
EvalMaybeTainted is an EvalNode that takes the planned change, new value, and possible error from an apply operation and produces a new instance object marked as tainted if it appears that a create operation has failed.
This EvalNode never returns an error, to ensure that a subsequent EvalNode can still record the possibly-tainted object in the state.
func (*EvalMaybeTainted) Eval ¶
func (n *EvalMaybeTainted) Eval(ctx EvalContext) (interface{}, error)
TODO: test
type EvalModuleCallArgument ¶
type EvalModuleCallArgument struct { Addr addrs.InputVariable Config *configs.Variable Expr hcl.Expression // If this flag is set, any diagnostics are discarded and this operation // will always succeed, though may produce an unknown value in the // event of an error. IgnoreDiagnostics bool Values map[string]cty.Value }
EvalModuleCallArgument is an EvalNode implementation that produces the value for a particular variable as will be used by a child module instance.
The result is written into the map given in Values, with its key set to the local name of the variable, disregarding the module instance address. Any existing values in that map are deleted first. This weird interface is a result of trying to be convenient for use with EvalContext.SetModuleCallArguments, which expects a map to merge in with any existing arguments.
func (*EvalModuleCallArgument) Eval ¶
func (n *EvalModuleCallArgument) Eval(ctx EvalContext) (interface{}, error)
type EvalNode ¶
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 ¶
func CloseProviderEvalTree(addr addrs.AbsProviderConfig) EvalNode
CloseProviderEvalTree returns the evaluation tree for closing provider connections that aren't needed anymore.
func EvalFilter ¶
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 ¶
func ProviderEvalTree(n *NodeApplyableProvider, config *configs.Provider) EvalNode
ProviderEvalTree returns the evaluation tree for initializing and configuring providers.
type EvalNodeFilterFunc ¶
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 ¶
func EvalNodeFilterOp(op walkOperation) EvalNodeFilterFunc
EvalNodeFilterOp returns a filter function that filters nodes that include themselves in specific operations.
type EvalNodeFilterable ¶
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 ¶
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 ¶
type EvalNoop struct{}
EvalNoop is an EvalNode that does nothing.
func (EvalNoop) Eval ¶
func (EvalNoop) Eval(EvalContext) (interface{}, error)
type EvalOpFilter ¶
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 ¶
func (n *EvalOpFilter) Eval(ctx EvalContext) (interface{}, error)
TODO: test
func (*EvalOpFilter) IncludeInOp ¶
func (n *EvalOpFilter) IncludeInOp(op walkOperation) bool
EvalNodeOpFilterable impl.
type EvalReadData ¶
type EvalReadData struct { Addr addrs.ResourceInstance Config *configs.Resource Dependencies []addrs.Referenceable Provider *providers.Interface ProviderAddr addrs.AbsProviderConfig ProviderSchema **ProviderSchema // Planned is set when dealing with data resources that were deferred to // the apply walk, to let us see what was planned. If this is set, the // evaluation of the config is required to produce a wholly-known // configuration which is consistent with the partial object included // in this planned change. Planned **plans.ResourceInstanceChange // ForcePlanRead, if true, overrides the usual behavior of immediately // reading from the data source where possible, instead forcing us to // _always_ generate a plan. This is used during the plan walk, since we // mustn't actually apply anything there. (The resulting state doesn't // get persisted) ForcePlanRead bool // The result from this EvalNode has a few different possibilities // depending on the input: // - If Planned is nil then we assume we're aiming to _produce_ the plan, // and so the following two outcomes are possible: // - OutputChange.Action is plans.NoOp and OutputState is the complete // result of reading from the data source. This is the easy path. // - OutputChange.Action is plans.Read and OutputState is a planned // object placeholder (states.ObjectPlanned). In this case, the // returned change must be recorded in the overral changeset and // eventually passed to another instance of this struct during the // apply walk. // - If Planned is non-nil then we assume we're aiming to complete a // planned read from an earlier plan walk. In this case the only possible // non-error outcome is to set Output.Action (if non-nil) to a plans.NoOp // change and put the complete resulting state in OutputState, ready to // be saved in the overall state and used for expression evaluation. OutputChange **plans.ResourceInstanceChange OutputValue *cty.Value OutputConfigValue *cty.Value OutputState **states.ResourceInstanceObject }
EvalReadData is an EvalNode implementation that deals with the main part of the data resource lifecycle: either actually reading from the data source or generating a plan to do so.
func (*EvalReadData) Eval ¶
func (n *EvalReadData) Eval(ctx EvalContext) (interface{}, error)
type EvalReadDataApply ¶
type EvalReadDataApply struct { Addr addrs.ResourceInstance Provider *providers.Interface ProviderAddr addrs.AbsProviderConfig ProviderSchema **ProviderSchema Output **states.ResourceInstanceObject Config *configs.Resource Change **plans.ResourceInstanceChange StateReferences []addrs.Referenceable }
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 EvalReadDiff ¶
type EvalReadDiff struct { Addr addrs.ResourceInstance DeposedKey states.DeposedKey ProviderSchema **ProviderSchema Change **plans.ResourceInstanceChange }
EvalReadDiff is an EvalNode implementation that retrieves the planned change for a particular resource instance object.
func (*EvalReadDiff) Eval ¶
func (n *EvalReadDiff) Eval(ctx EvalContext) (interface{}, error)
type EvalReadState ¶
type EvalReadState struct { // Addr is the address of the instance to read state for. Addr addrs.ResourceInstance // ProviderSchema is the schema for the provider given in Provider. ProviderSchema **ProviderSchema // Provider is the provider that will subsequently perform actions on // the the state object. This is used to perform any schema upgrades // that might be required to prepare the stored data for use. Provider *providers.Interface // Output will be written with a pointer to the retrieved object. Output **states.ResourceInstanceObject }
EvalReadState is an EvalNode implementation that reads the current object for a specific instance in the state.
func (*EvalReadState) Eval ¶
func (n *EvalReadState) Eval(ctx EvalContext) (interface{}, error)
type EvalReadStateDeposed ¶
type EvalReadStateDeposed struct { // Addr is the address of the instance to read state for. Addr addrs.ResourceInstance // Key identifies which deposed object we will read. Key states.DeposedKey // ProviderSchema is the schema for the provider given in Provider. ProviderSchema **ProviderSchema // Provider is the provider that will subsequently perform actions on // the the state object. This is used to perform any schema upgrades // that might be required to prepare the stored data for use. Provider *providers.Interface // Output will be written with a pointer to the retrieved object. Output **states.ResourceInstanceObject }
EvalReadStateDeposed is an EvalNode implementation that reads the deposed InstanceState for a specific resource out of the state
func (*EvalReadStateDeposed) Eval ¶
func (n *EvalReadStateDeposed) Eval(ctx EvalContext) (interface{}, error)
type EvalReduceDiff ¶
type EvalReduceDiff struct { Addr addrs.ResourceInstance InChange **plans.ResourceInstanceChange Destroy bool OutChange **plans.ResourceInstanceChange }
EvalReduceDiff is an EvalNode implementation that takes a planned resource instance change as might be produced by EvalDiff or EvalDiffDestroy and "simplifies" it to a single atomic action to be performed by a specific graph node.
Callers must specify whether they are a destroy node or a regular apply node. If the result is NoOp then the given change requires no action for the specific graph node calling this and so evaluation of the that graph node should exit early and take no action.
The object written to OutChange may either be identical to InChange or a new change object derived from InChange. Because of the former case, the caller must not mutate the object returned in OutChange.
func (*EvalReduceDiff) Eval ¶
func (n *EvalReduceDiff) Eval(ctx EvalContext) (interface{}, error)
TODO: test
type EvalRefresh ¶
type EvalRefresh struct { Addr addrs.ResourceInstance ProviderAddr addrs.AbsProviderConfig Provider *providers.Interface ProviderSchema **ProviderSchema State **states.ResourceInstanceObject Output **states.ResourceInstanceObject }
EvalRefresh is an EvalNode implementation that does a refresh for a resource.
func (*EvalRefresh) Eval ¶
func (n *EvalRefresh) Eval(ctx EvalContext) (interface{}, error)
TODO: test
type EvalRequireState ¶
type EvalRequireState struct {
State **states.ResourceInstanceObject
}
EvalRequireState is an EvalNode implementation that exits early if the given object is null.
func (*EvalRequireState) Eval ¶
func (n *EvalRequireState) Eval(ctx EvalContext) (interface{}, error)
type EvalReturnError ¶
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 ¶
func (n *EvalReturnError) Eval(ctx EvalContext) (interface{}, error)
type EvalSequence ¶
type EvalSequence struct {
Nodes []EvalNode
}
EvalSequence is an EvalNode that evaluates in sequence.
func (*EvalSequence) Eval ¶
func (n *EvalSequence) Eval(ctx EvalContext) (interface{}, error)
func (*EvalSequence) Filter ¶
func (n *EvalSequence) Filter(fn EvalNodeFilterFunc)
EvalNodeFilterable impl.
type EvalSetModuleCallArguments ¶
type EvalSetModuleCallArguments struct { Module addrs.ModuleCallInstance Values map[string]cty.Value }
EvalSetModuleCallArguments is an EvalNode implementation that sets values for arguments of a child module call, for later retrieval during expression evaluation.
func (*EvalSetModuleCallArguments) Eval ¶
func (n *EvalSetModuleCallArguments) Eval(ctx EvalContext) (interface{}, error)
TODO: test
type EvalUpdateStateHook ¶
type EvalUpdateStateHook struct{}
EvalUpdateStateHook is an EvalNode implementation that calls the PostStateUpdate hook with the current state.
func (*EvalUpdateStateHook) Eval ¶
func (n *EvalUpdateStateHook) Eval(ctx EvalContext) (interface{}, error)
type EvalValidateCount ¶
EvalValidateCount is an EvalNode implementation that validates the count of a resource.
func (*EvalValidateCount) Eval ¶
func (n *EvalValidateCount) Eval(ctx EvalContext) (interface{}, error)
TODO: test
type EvalValidateProvider ¶
type EvalValidateProvider struct { Addr addrs.ProviderConfig Provider *providers.Interface Config *configs.Provider }
EvalValidateProvider is an EvalNode implementation that validates a provider configuration.
func (*EvalValidateProvider) Eval ¶
func (n *EvalValidateProvider) Eval(ctx EvalContext) (interface{}, error)
type EvalValidateProvisioner ¶
type EvalValidateProvisioner struct { ResourceAddr addrs.Resource Provisioner *provisioners.Interface Schema **configschema.Block Config *configs.Provisioner ResourceHasCount bool ResourceHasForEach bool }
EvalValidateProvisioner is an EvalNode implementation that validates the configuration of a provisioner belonging to a resource. The provisioner config is expected to contain the merged connection configurations.
func (*EvalValidateProvisioner) Eval ¶
func (n *EvalValidateProvisioner) Eval(ctx EvalContext) (interface{}, error)
type EvalValidateResource ¶
type EvalValidateResource struct { Addr addrs.Resource Provider *providers.Interface ProviderSchema **ProviderSchema Config *configs.Resource // IgnoreWarnings means that warnings will not be passed through. This allows // "just-in-time" passes of validation to continue execution through warnings. IgnoreWarnings bool // ConfigVal, if non-nil, will be updated with the value resulting from // evaluating the given configuration body. Since validation is performed // very early, this value is likely to contain lots of unknown values, // but its type will conform to the schema of the resource type associated // with the resource instance being validated. ConfigVal *cty.Value }
EvalValidateResource is an EvalNode implementation that validates the configuration of a resource.
func (*EvalValidateResource) Eval ¶
func (n *EvalValidateResource) Eval(ctx EvalContext) (interface{}, error)
type EvalValidateSelfRef ¶
type EvalValidateSelfRef struct { Addr addrs.Referenceable Config hcl.Body ProviderSchema **ProviderSchema }
EvalValidateSelfRef is an EvalNode implementation that checks to ensure that expressions within a particular referencable block do not reference that same block.
func (*EvalValidateSelfRef) Eval ¶
func (n *EvalValidateSelfRef) Eval(ctx EvalContext) (interface{}, error)
type EvalWriteDiff ¶
type EvalWriteDiff struct { Addr addrs.ResourceInstance DeposedKey states.DeposedKey ProviderSchema **ProviderSchema Change **plans.ResourceInstanceChange }
EvalWriteDiff is an EvalNode implementation that saves a planned change for an instance object into the set of global planned changes.
func (*EvalWriteDiff) Eval ¶
func (n *EvalWriteDiff) Eval(ctx EvalContext) (interface{}, error)
TODO: test
type EvalWriteOutput ¶
type EvalWriteOutput struct { Addr addrs.OutputValue Sensitive bool Expr hcl.Expression // ContinueOnErr allows interpolation to fail during Input ContinueOnErr bool }
EvalWriteOutput is an EvalNode implementation that writes the output for the given name to the current state.
func (*EvalWriteOutput) Eval ¶
func (n *EvalWriteOutput) Eval(ctx EvalContext) (interface{}, error)
TODO: test
type EvalWriteResourceState ¶
type EvalWriteResourceState struct { Addr addrs.Resource Config *configs.Resource ProviderAddr addrs.AbsProviderConfig }
EvalWriteResourceState is an EvalNode implementation that ensures that a suitable resource-level state record is present in the state, if that's required for the "each mode" of that resource.
This is important primarily for the situation where count = 0, since this eval is the only change we get to set the resource "each mode" to list in that case, allowing expression evaluation to see it as a zero-element list rather than as not set at all.
func (*EvalWriteResourceState) Eval ¶
func (n *EvalWriteResourceState) Eval(ctx EvalContext) (interface{}, error)
TODO: test
type EvalWriteState ¶
type EvalWriteState struct { // Addr is the address of the instance to read state for. Addr addrs.ResourceInstance // State is the object state to save. State **states.ResourceInstanceObject // ProviderSchema is the schema for the provider given in ProviderAddr. ProviderSchema **ProviderSchema // ProviderAddr is the address of the provider configuration that // produced the given object. ProviderAddr addrs.AbsProviderConfig }
EvalWriteState is an EvalNode implementation that saves the given object as the current object for the selected resource instance.
func (*EvalWriteState) Eval ¶
func (n *EvalWriteState) Eval(ctx EvalContext) (interface{}, error)
type EvalWriteStateDeposed ¶
type EvalWriteStateDeposed struct { // Addr is the address of the instance to read state for. Addr addrs.ResourceInstance // Key indicates which deposed object to write to. Key states.DeposedKey // State is the object state to save. State **states.ResourceInstanceObject // ProviderSchema is the schema for the provider given in ProviderAddr. ProviderSchema **ProviderSchema // ProviderAddr is the address of the provider configuration that // produced the given object. ProviderAddr addrs.AbsProviderConfig }
EvalWriteStateDeposed is an EvalNode implementation that writes an InstanceState out to the Deposed list of a resource in the state.
func (*EvalWriteStateDeposed) Eval ¶
func (n *EvalWriteStateDeposed) Eval(ctx EvalContext) (interface{}, error)
type Evaluator ¶
type Evaluator struct { // Operation defines what type of operation this evaluator is being used // for. Operation walkOperation // Meta is contextual metadata about the current operation. Meta *ContextMeta // Config is the root node in the configuration tree. Config *configs.Config // VariableValues is a map from variable names to their associated values, // within the module indicated by ModulePath. VariableValues is modified // concurrently, and so it must be accessed only while holding // VariableValuesLock. // // The first map level is string representations of addr.ModuleInstance // values, while the second level is variable names. VariableValues map[string]map[string]cty.Value VariableValuesLock *sync.Mutex // Schemas is a repository of all of the schemas we should need to // evaluate expressions. This must be constructed by the caller to // include schemas for all of the providers, resource types, data sources // and provisioners used by the given configuration and state. // // This must not be mutated during evaluation. Schemas *Schemas // State is the current state, embedded in a wrapper that ensures that // it can be safely accessed and modified concurrently. State *states.SyncState // Changes is the set of proposed changes, embedded in a wrapper that // ensures they can be safely accessed and modified concurrently. Changes *plans.ChangesSync }
Evaluator provides the necessary contextual data for evaluating expressions for a particular walk operation.
type ExpandTransform ¶
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.
type ForcedCBDTransformer ¶
type ForcedCBDTransformer struct { }
ForcedCBDTransformer detects when a particular CBD-able graph node has dependencies with another that has create_before_destroy set that require it to be forced on, and forces it on.
This must be used in the plan graph builder to ensure that create_before_destroy settings are properly propagated before constructing the planned changes. This requires that the plannable resource nodes implement GraphNodeDestroyerCBD.
func (*ForcedCBDTransformer) Transform ¶
func (t *ForcedCBDTransformer) 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. Path addrs.ModuleInstance // contains filtered or unexported fields }
Graph represents the graph that Terraform uses to represent resources and their dependencies.
func (*Graph) DirectedGraph ¶
func (*Graph) Walk ¶
func (g *Graph) Walk(walker GraphWalker) tfdiags.Diagnostics
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 ¶
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(addrs.ModuleInstance) (*Graph, tfdiags.Diagnostics) }
GraphBuilder is an interface that can be implemented and used with Terraform to build the graph that Terraform walks.
func ValidateGraphBuilder ¶
func ValidateGraphBuilder(p *PlanGraphBuilder) GraphBuilder
ValidateGraphBuilder creates the graph for the validate operation.
ValidateGraphBuilder is based on the PlanGraphBuilder. We do this so that we only have to validate what we'd normally plan anyways. The PlanGraphBuilder given will be modified so it shouldn't be used for anything else after calling this function.
type GraphNodeAttachDestroyer ¶
type GraphNodeAttachDestroyer interface { // AttachDestroyNode takes a destroy node and saves a reference to that // node in the receiver, so it can later check the status of // CreateBeforeDestroy(). AttachDestroyNode(n GraphNodeDestroyerCBD) }
GraphNodeAttachDestroyer is implemented by applyable nodes that have a companion destroy node. This allows the creation node to look up the status of the destroy node and determine if it needs to depose the existing state, or replace it. If a node is not marked as create-before-destroy in the configuration, but a dependency forces that status, only the destroy node will be aware of that status.
type GraphNodeAttachProvider ¶
type GraphNodeAttachProvider interface { // Must be implemented to determine the path for the configuration GraphNodeSubPath // ProviderName with no module prefix. Example: "aws". ProviderAddr() addrs.AbsProviderConfig // Sets the configuration AttachProvider(*configs.Provider) }
GraphNodeAttachProvider is an interface that must be implemented by nodes that want provider configurations attached.
type GraphNodeAttachProviderConfigSchema ¶
type GraphNodeAttachProviderConfigSchema interface { GraphNodeProvider AttachProviderConfigSchema(*configschema.Block) }
GraphNodeAttachProviderConfigSchema is an interface implemented by node types that need a provider configuration schema attached.
type GraphNodeAttachProvisionerSchema ¶
type GraphNodeAttachProvisionerSchema interface { ProvisionedBy() []string // SetProvisionerSchema is called during transform for each provisioner // type returned from ProvisionedBy, providing the configuration schema // for each provisioner in turn. The implementer should save these for // later use in evaluating provisioner configuration blocks. AttachProvisionerSchema(name string, schema *configschema.Block) }
GraphNodeAttachProvisionerSchema is an interface implemented by node types that need one or more provisioner schemas attached.
type GraphNodeAttachResourceConfig ¶
type GraphNodeAttachResourceConfig interface { GraphNodeResource // Sets the configuration AttachResourceConfig(*configs.Resource) }
GraphNodeAttachResourceConfig is an interface that must be implemented by nodes that want resource configurations attached.
type GraphNodeAttachResourceSchema ¶
type GraphNodeAttachResourceSchema interface { GraphNodeResource GraphNodeProviderConsumer AttachResourceSchema(schema *configschema.Block, version uint64) }
GraphNodeAttachResourceSchema is an interface implemented by node types that need a resource schema attached.
type GraphNodeAttachResourceState ¶
type GraphNodeAttachResourceState interface { GraphNodeResourceInstance // Sets the state AttachResourceState(*states.Resource) }
GraphNodeAttachResourceState is an interface that can be implemented to request that a ResourceState is attached to the node.
Due to a historical naming inconsistency, the type ResourceState actually represents the state for a particular _instance_, while InstanceState represents the values for that instance during a particular phase (e.g. primary vs. deposed). Consequently, GraphNodeAttachResourceState is supported only for nodes that represent resource instances, even though the name might suggest it is for containing resources.
type GraphNodeCloseProvider ¶
type GraphNodeCloseProvider interface { GraphNodeSubPath CloseProviderAddr() addrs.AbsProviderConfig }
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 ¶
type GraphNodeCloseProvisioner interface {
CloseProvisionerName() string
}
GraphNodeCloseProvisioner is an interface that nodes that can be a close provisioner must implement. The CloseProvisionerName returned is the name of the provisioner they satisfy.
type GraphNodeCreator ¶
type GraphNodeCreator interface { // CreateAddr is the address of the resource being created or updated CreateAddr() *addrs.AbsResourceInstance }
GraphNodeCreator must be implemented by nodes that create OR update resources.
type GraphNodeDeposedResourceInstanceObject ¶
type GraphNodeDeposedResourceInstanceObject interface {
DeposedInstanceObjectKey() states.DeposedKey
}
type GraphNodeDeposer ¶
type GraphNodeDeposer interface { // SetPreallocatedDeposedKey will be called during graph construction // if a particular node must use a pre-allocated deposed key if/when it // "deposes" the current object of its associated resource instance. SetPreallocatedDeposedKey(key states.DeposedKey) }
GraphNodeDeposer is an optional interface implemented by graph nodes that might create a single new deposed object for a specific associated resource instance, allowing a caller to optionally pre-allocate a DeposedKey for it.
type GraphNodeDestroyer ¶
type GraphNodeDestroyer interface { dag.Vertex // DestroyAddr is the address of the resource that is being // destroyed by this node. If this returns nil, then this node // is not destroying anything. DestroyAddr() *addrs.AbsResourceInstance }
GraphNodeDestroyer must be implemented by nodes that destroy resources.
type GraphNodeDestroyerCBD ¶
type GraphNodeDestroyerCBD interface { // CreateBeforeDestroy returns true if this node represents a node // that is doing a CBD. CreateBeforeDestroy() bool // ModifyCreateBeforeDestroy is called when the CBD state of a node // is changed dynamically. This can return an error if this isn't // allowed. ModifyCreateBeforeDestroy(bool) error }
GraphNodeDestroyerCBD must be implemented by nodes that might be create-before-destroy destroyers, or might plan a create-before-destroy action.
type GraphNodeDynamicExpandable ¶
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 ¶
type GraphNodeEvalable interface {
EvalTree() EvalNode
}
GraphNodeEvalable is the interface that graph nodes must implement to enable valuation.
type GraphNodeExpandable ¶
type GraphNodeExpandable interface {
Expand(GraphBuilder) (GraphNodeSubgraph, error)
}
GraphNodeExapndable is an interface that nodes can implement to signal that they can be expanded. Expanded nodes turn into GraphNodeSubgraph nodes within the graph.
type GraphNodeProvider ¶
type GraphNodeProvider interface { GraphNodeSubPath ProviderAddr() addrs.AbsProviderConfig Name() string }
GraphNodeProvider is an interface that nodes that can be a provider must implement.
ProviderAddr returns the address of the provider configuration this satisfies, which is relative to the path returned by method Path().
Name returns the full name of the provider in the config.
type GraphNodeProviderConsumer ¶
type GraphNodeProviderConsumer interface { // ProvidedBy returns the address of the provider configuration the node // refers to. If the returned "exact" value is true, this address will // be taken exactly. If "exact" is false, a provider configuration from // an ancestor module may be selected instead. ProvidedBy() (addr addrs.AbsProviderConfig, exact bool) // Set the resolved provider address for this resource. SetProvider(addrs.AbsProviderConfig) }
GraphNodeProviderConsumer is an interface that nodes that require a provider must implement. ProvidedBy must return the address of the provider to use, which will be resolved to a configuration either in the same module or in an ancestor module, with the resulting absolute address passed to SetProvider.
type GraphNodeProvisioner ¶
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 ¶
type GraphNodeProvisionerConsumer interface {
ProvisionedBy() []string
}
GraphNodeProvisionerConsumer is an interface that nodes that require a provisioner must implement. ProvisionedBy must return the names of the provisioners to use.
type GraphNodeReferenceOutside ¶
type GraphNodeReferenceOutside interface { // ReferenceOutside returns a path in which any references from this node // are resolved. ReferenceOutside() (selfPath, referencePath addrs.ModuleInstance) }
GraphNodeReferenceOutside is an interface that can optionally be implemented. A node that implements it can specify that its own referenceable addresses and/or the addresses it references are in a different module than the node itself.
Any referenceable addresses returned by ReferenceableAddrs are interpreted relative to the returned selfPath.
Any references returned by References are interpreted relative to the returned referencePath.
It is valid but not required for either of these paths to match what is returned by method Path, though if both match the main Path then there is no reason to implement this method.
The primary use-case for this is the nodes representing module input variables, since their expressions are resolved in terms of their calling module, but they are still referenced from their own module.
type GraphNodeReferenceable ¶
type GraphNodeReferenceable interface { GraphNodeSubPath // ReferenceableAddrs returns a list of addresses through which this can be // referenced. ReferenceableAddrs() []addrs.Referenceable }
GraphNodeReferenceable must be implemented by any node that represents a Terraform thing that can be referenced (resource, module, etc.).
Even if the thing has no name, this should return an empty list. By implementing this and returning a non-nil result, you say that this CAN be referenced and other methods of referencing may still be possible (such as by path!)
type GraphNodeReferencer ¶
type GraphNodeReferencer interface { GraphNodeSubPath // References returns a list of references made by this node, which // include both a referenced address and source location information for // the reference. References() []*addrs.Reference }
GraphNodeReferencer must be implemented by nodes that reference other Terraform items and therefore depend on them.
type GraphNodeResource ¶
type GraphNodeResource interface {
ResourceAddr() addrs.AbsResource
}
GraphNodeResource is implemented by any nodes that represent a resource. The type of operation cannot be assumed, only that this node represents the given resource.
type GraphNodeResourceInstance ¶
type GraphNodeResourceInstance interface {
ResourceInstanceAddr() addrs.AbsResourceInstance
}
GraphNodeResourceInstance is implemented by any nodes that represent a resource instance. A single resource may have multiple instances if, for example, the "count" or "for_each" argument is used for it in configuration.
type GraphNodeSubPath ¶
type GraphNodeSubPath interface {
Path() addrs.ModuleInstance
}
GraphNodeSubPath says that a node is part of a graph with a different path, and the context should be adjusted accordingly.
type GraphNodeSubgraph ¶
GraphNodeSubgraph is an interface a node can implement if it has a larger subgraph that should be walked.
type GraphNodeTargetDownstream ¶
GraphNodeTargetDownstream is an interface for graph nodes that need to be remain present under targeting if any of their dependencies are targeted. TargetDownstream is called with the set of vertices that are direct dependencies for the node, and it should return true if the node must remain in the graph in support of those dependencies.
This is used in situations where the dependency edges are representing an ordering relationship but the dependency must still be visited if its dependencies are visited. This is true for outputs, for example, since they must get updated if any of their dependent resources get updated, which would not normally be true if one of their dependencies were targeted.
type GraphNodeTargetable ¶
type GraphNodeTargetable interface {
SetTargets([]addrs.Targetable)
}
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 GraphTransformer ¶
GraphTransformer is the interface that transformers implement. This interface is only for transforms that need entire graph visibility.
func GraphTransformIf ¶
func GraphTransformIf(f func() bool, then GraphTransformer) GraphTransformer
GraphTransformIf is a helper function that conditionally returns a GraphTransformer given. This is useful for calling inline a sequence of transforms without having to split it up into multiple append() calls.
func GraphTransformMulti ¶
func GraphTransformMulti(ts ...GraphTransformer) GraphTransformer
GraphTransformMulti combines multiple graph transformers into a single GraphTransformer that runs all the individual graph transformers.
func TransformProviders ¶
func TransformProviders(providers []string, concrete ConcreteProviderNodeFunc, config *configs.Config) GraphTransformer
type GraphType ¶
type GraphType byte
GraphType is an enum of the type of graph to create with a Context. The values of the constants may change so they shouldn't be depended on; always use the constant name.
type GraphVertexTransformer ¶
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 ¶
type GraphWalker interface { EnterPath(addrs.ModuleInstance) EvalContext ExitPath(addrs.ModuleInstance) EnterVertex(dag.Vertex) ExitVertex(dag.Vertex, tfdiags.Diagnostics) EnterEvalTree(dag.Vertex, EvalNode) EvalNode ExitEvalTree(dag.Vertex, interface{}, error) tfdiags.Diagnostics }
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 an action for a // single instance is applied. The error argument in PostApply is the // error, if any, that was returned from the provider Apply call itself. PreApply(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, priorState, plannedNewState cty.Value) (HookAction, error) PostApply(addr addrs.AbsResourceInstance, gen states.Generation, newState cty.Value, err error) (HookAction, error) // PreDiff and PostDiff are called before and after a provider is given // the opportunity to customize the proposed new state to produce the // planned new state. PreDiff(addr addrs.AbsResourceInstance, gen states.Generation, priorState, proposedNewState cty.Value) (HookAction, error) PostDiff(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, priorState, plannedNewState cty.Value) (HookAction, error) // The provisioning hooks signal both the overall start end end of // provisioning for a particular instance and of each of the individual // configured provisioners for each instance. The sequence of these // for a given instance might look something like this: // // PreProvisionInstance(aws_instance.foo[1], ...) // PreProvisionInstanceStep(aws_instance.foo[1], "file") // PostProvisionInstanceStep(aws_instance.foo[1], "file", nil) // PreProvisionInstanceStep(aws_instance.foo[1], "remote-exec") // ProvisionOutput(aws_instance.foo[1], "remote-exec", "Installing foo...") // ProvisionOutput(aws_instance.foo[1], "remote-exec", "Configuring bar...") // PostProvisionInstanceStep(aws_instance.foo[1], "remote-exec", nil) // PostProvisionInstance(aws_instance.foo[1], ...) // // ProvisionOutput is called with output sent back by the provisioners. // This will be called multiple times as output comes in, with each call // representing one line of output. It cannot control whether the // provisioner continues running. PreProvisionInstance(addr addrs.AbsResourceInstance, state cty.Value) (HookAction, error) PostProvisionInstance(addr addrs.AbsResourceInstance, state cty.Value) (HookAction, error) PreProvisionInstanceStep(addr addrs.AbsResourceInstance, typeName string) (HookAction, error) PostProvisionInstanceStep(addr addrs.AbsResourceInstance, typeName string, err error) (HookAction, error) ProvisionOutput(addr addrs.AbsResourceInstance, typeName string, line string) // PreRefresh and PostRefresh are called before and after a single // resource state is refreshed, respectively. PreRefresh(addr addrs.AbsResourceInstance, gen states.Generation, priorState cty.Value) (HookAction, error) PostRefresh(addr addrs.AbsResourceInstance, gen states.Generation, priorState cty.Value, newState cty.Value) (HookAction, error) // PreImportState and PostImportState are called before and after // (respectively) each state import operation for a given resource address. PreImportState(addr addrs.AbsResourceInstance, importID string) (HookAction, error) PostImportState(addr addrs.AbsResourceInstance, imported []providers.ImportedResource) (HookAction, error) // PostStateUpdate is called each time the state is updated. It receives // a deep copy of the state, which it may therefore access freely without // any need for locks to protect from concurrent writes from the caller. PostStateUpdate(new *states.State) (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 a configuration to build the graph from. See ImportOpts.Config. Config *configs.Config // Components is the factory for our available plugin components. Components contextComponentFactory // Schemas is the repository of schemas we will draw from to analyse // the configuration. Schemas *Schemas }
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 addrs.ModuleInstance) (*Graph, tfdiags.Diagnostics)
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 // Config is optional, and specifies a config tree that will be loaded // into the graph and evaluated. This is the source for provider // configurations. Config *configs.Config }
ImportOpts are used as the configuration for Import.
type ImportProviderValidateTransformer ¶
type ImportProviderValidateTransformer struct{}
ImportProviderValidateTransformer is a GraphTransformer that goes through the providers in the graph and validates that they only depend on variables.
func (*ImportProviderValidateTransformer) Transform ¶
func (t *ImportProviderValidateTransformer) Transform(g *Graph) error
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 address for the resource instance that the new object should // be imported into. Addr addrs.AbsResourceInstance // ID is the ID of the resource to import. This is resource-specific. ID string // ProviderAddr is the address of the provider that should handle the import. ProviderAddr addrs.AbsProviderConfig }
ImportTarget is a single resource to import.
type InputMode ¶
type InputMode byte
InputMode defines what sort of input will be asked for when Input is called on Context.
const ( // InputModeVar asks for all variables InputModeVar InputMode = 1 << iota // InputModeVarUnset asks for variables which are not set yet. // InputModeVar must be set for this to have an effect. InputModeVarUnset // InputModeProvider asks for provider variables InputModeProvider // InputModeStd is the standard operating mode and asks for both variables // and providers. InputModeStd = InputModeVar | InputModeProvider )
type InputOpts ¶
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 InputValue ¶
type InputValue struct { Value cty.Value SourceType ValueSourceType // SourceRange provides source location information for values whose // SourceType is either ValueFromConfig or ValueFromFile. It is not // populated for other source types, and so should not be used. SourceRange tfdiags.SourceRange }
InputValue represents a value for a variable in the root module, provided as part of the definition of an operation.
func (*InputValue) GoString ¶
func (v *InputValue) GoString() string
type InputValues ¶
type InputValues map[string]*InputValue
InputValues is a map of InputValue instances.
func DefaultVariableValues ¶
func DefaultVariableValues(configs map[string]*configs.Variable) InputValues
DefaultVariableValues returns an InputValues map representing the default values specified for variables in the given configuration map.
func InputValuesFromCaller ¶
func InputValuesFromCaller(vals map[string]cty.Value) InputValues
InputValuesFromCaller turns the given map of naked values into an InputValues that attributes each value to "a caller", using the source type ValueFromCaller. This is primarily useful for testing purposes.
This should not be used as a general way to convert map[string]cty.Value into InputValues, since in most real cases we want to set a suitable other SourceType and possibly SourceRange value.
func (InputValues) HasValues ¶
func (vv InputValues) HasValues(vals map[string]cty.Value) bool
HasValues returns true if the reciever has the same values as in the given map, disregarding the source types and source ranges.
Values are compared using the cty "RawEquals" method, which means that unknown values can be considered equal to one another if they are of the same type.
func (InputValues) Identical ¶
func (vv InputValues) Identical(other InputValues) bool
Identical returns true if the given InputValues has the same values, source types, and source ranges as the receiver.
Values are compared using the cty "RawEquals" method, which means that unknown values can be considered equal to one another if they are of the same type.
This method is primarily for testing. For most practical purposes, it's better to use SameValues or HasValues.
func (InputValues) JustValues ¶
func (vv InputValues) JustValues() map[string]cty.Value
JustValues returns a map that just includes the values, discarding the source information.
func (InputValues) Override ¶
func (vv InputValues) Override(others ...InputValues) InputValues
Override merges the given value maps with the receiver, overriding any conflicting keys so that the latest definition wins.
func (InputValues) SameValues ¶
func (vv InputValues) SameValues(other InputValues) bool
SameValues returns true if the given InputValues has the same values as the receiever, disregarding the source types and source ranges.
Values are compared using the cty "RawEquals" method, which means that unknown values can be considered equal to one another if they are of the same type.
type InstanceDiff ¶
type InstanceDiff struct { Attributes map[string]*ResourceAttrDiff Destroy bool DestroyDeposed bool DestroyTainted bool // Meta is a simple K/V map that is stored in a diff and persisted to // plans but otherwise is completely ignored by Terraform core. It is // meant to be used for additional data a resource may want to pass through. // The value here must only contain Go primitives and collections. Meta map[string]interface{} // contains filtered or unexported fields }
InstanceDiff is the diff of a resource from some state to another.
func NewInstanceDiff ¶
func NewInstanceDiff() *InstanceDiff
func (*InstanceDiff) Apply ¶
func (d *InstanceDiff) Apply(attrs map[string]string, schema *configschema.Block) (map[string]string, error)
Apply applies the diff to the provided flatmapped attributes, returning the new instance attributes.
This method is intended for shimming old subsystems that still use this legacy diff type to work with the new-style types.
func (*InstanceDiff) ApplyToValue ¶
func (d *InstanceDiff) ApplyToValue(base cty.Value, schema *configschema.Block) (cty.Value, error)
ApplyToValue merges the receiver into the given base value, returning a new value that incorporates the planned changes. The given value must conform to the given schema, or this method will panic.
This method is intended for shimming old subsystems that still use this legacy diff type to work with the new-style types.
func (*InstanceDiff) ChangeType ¶
func (d *InstanceDiff) ChangeType() DiffChangeType
ChangeType returns the DiffChangeType represented by the diff for this single instance.
func (*InstanceDiff) Copy ¶
func (d *InstanceDiff) Copy() (*InstanceDiff, error)
func (*InstanceDiff) CopyAttributes ¶
func (d *InstanceDiff) CopyAttributes() map[string]*ResourceAttrDiff
Safely copies the Attributes map
func (*InstanceDiff) DeepCopy ¶
func (d *InstanceDiff) DeepCopy() *InstanceDiff
DeepCopy performs a deep copy of all parts of the InstanceDiff
func (*InstanceDiff) DelAttribute ¶
func (d *InstanceDiff) DelAttribute(key string)
func (*InstanceDiff) Empty ¶
func (d *InstanceDiff) Empty() bool
Empty returns true if this diff encapsulates no changes.
func (*InstanceDiff) Equal ¶
func (d *InstanceDiff) Equal(d2 *InstanceDiff) bool
Equal compares two diffs for exact equality.
This is different from the Same comparison that is supported which checks for operation equality taking into account computed values. Equal instead checks for exact equality.
func (*InstanceDiff) GetAttribute ¶
func (d *InstanceDiff) GetAttribute(key string) (*ResourceAttrDiff, bool)
func (*InstanceDiff) GetAttributesLen ¶
func (d *InstanceDiff) GetAttributesLen() int
func (*InstanceDiff) GetDestroy ¶
func (d *InstanceDiff) GetDestroy() bool
func (*InstanceDiff) GetDestroyDeposed ¶
func (d *InstanceDiff) GetDestroyDeposed() bool
func (*InstanceDiff) GetDestroyTainted ¶
func (d *InstanceDiff) GetDestroyTainted() bool
func (*InstanceDiff) GoString ¶
func (d *InstanceDiff) GoString() string
func (*InstanceDiff) Lock ¶
func (d *InstanceDiff) Lock()
func (*InstanceDiff) RequiresNew ¶
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 ¶
func (d *InstanceDiff) Same(d2 *InstanceDiff) (bool, string)
Same checks whether or not two InstanceDiff's are the "same". When we say "same", it is not necessarily exactly equal. Instead, it is just checking that the same attributes are changing, a destroy isn't suddenly happening, etc.
func (*InstanceDiff) SetAttribute ¶
func (d *InstanceDiff) SetAttribute(key string, attr *ResourceAttrDiff)
func (*InstanceDiff) SetDestroy ¶
func (d *InstanceDiff) SetDestroy(b bool)
func (*InstanceDiff) SetDestroyDeposed ¶
func (d *InstanceDiff) SetDestroyDeposed(b bool)
func (*InstanceDiff) SetTainted ¶
func (d *InstanceDiff) SetTainted(b bool)
These methods are properly locked, for use outside other InstanceDiff methods but everywhere else within the terraform package. TODO refactor the locking scheme
func (*InstanceDiff) Unlock ¶
func (d *InstanceDiff) Unlock()
type InstanceInfo ¶
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 NewInstanceInfo ¶
func NewInstanceInfo(addr addrs.AbsResourceInstance) *InstanceInfo
NewInstanceInfo constructs an InstanceInfo from an addrs.AbsResourceInstance.
InstanceInfo is a legacy type, and uses of it should be gradually replaced by direct use of addrs.AbsResource or addrs.AbsResourceInstance as appropriate.
The legacy InstanceInfo type cannot represent module instances with instance keys, so this function will panic if given such a path. Uses of this type should all be removed or replaced before implementing "count" and "for_each" arguments on modules in order to avoid such panics.
This legacy type also cannot represent resource instances with string instance keys. It will panic if the given key is not either NoKey or an IntKey.
func (*InstanceInfo) ResourceAddress ¶
func (i *InstanceInfo) ResourceAddress() *ResourceAddress
ResourceAddress returns the address of the resource that the receiver is describing.
type InstanceKeyEvalData ¶
type InstanceKeyEvalData struct { // CountIndex is the value for count.index, or cty.NilVal if evaluating // in a context where the "count" argument is not active. // // For correct operation, this should always be of type cty.Number if not // nil. CountIndex cty.Value // EachKey and EachValue are the values for each.key and each.value // respectively, or cty.NilVal if evaluating in a context where the // "for_each" argument is not active. These must either both be set // or neither set. // // For correct operation, EachKey must always be either of type cty.String // or cty.Number if not nil. EachKey, EachValue cty.Value }
InstanceKeyEvalData is used during evaluation to specify which values, if any, should be produced for count.index, each.key, and each.value.
func EvalDataForInstanceKey ¶
func EvalDataForInstanceKey(key addrs.InstanceKey, forEachMap map[string]cty.Value) InstanceKeyEvalData
EvalDataForInstanceKey constructs a suitable InstanceKeyEvalData for evaluating in a context that has the given instance key.
type InstanceState ¶
type InstanceState struct { // A unique ID for this resource. This is opaque to Terraform // and is only meant as a lookup mechanism for the providers. ID string `json:"id"` // Attributes are basic information about the resource. Any keys here // are accessible in variable format within Terraform configurations: // ${resourcetype.name.attribute}. Attributes map[string]string `json:"attributes"` // Ephemeral is used to store any state associated with this instance // that is necessary for the Terraform run to complete, but is not // persisted to a state file. Ephemeral EphemeralState `json:"-"` // Meta is a simple K/V map that is persisted to the State but otherwise // ignored by Terraform core. It's meant to be used for accounting by // external client code. The value here must only contain Go primitives // and collections. Meta map[string]interface{} `json:"meta"` // Tainted is used to mark a resource for recreation. Tainted bool `json:"tainted"` // contains filtered or unexported fields }
InstanceState is used to track the unique state information belonging to a given instance.
func NewInstanceStateShimmedFromValue ¶
func NewInstanceStateShimmedFromValue(state cty.Value, schemaVersion int) *InstanceState
NewInstanceStateShimmedFromValue is a shim method to lower a new-style object value representing the attributes of an instance object into the legacy InstanceState representation.
This is for shimming to old components only and should not be used in new code.
func (*InstanceState) AttrsAsObjectValue ¶
AttrsAsObjectValue shims from the legacy InstanceState representation to a new-style cty object value representation of the state attributes, using the given type for guidance.
The given type must be the implied type of the schema of the resource type of the object whose state is being converted, or the result is undefined.
This is for shimming from old components only and should not be used in new code.
func (*InstanceState) DeepCopy ¶
func (s *InstanceState) DeepCopy() *InstanceState
func (*InstanceState) Empty ¶
func (s *InstanceState) Empty() bool
func (*InstanceState) Equal ¶
func (s *InstanceState) Equal(other *InstanceState) bool
func (*InstanceState) Lock ¶
func (s *InstanceState) Lock()
func (*InstanceState) MergeDiff ¶
func (s *InstanceState) MergeDiff(d *InstanceDiff) *InstanceState
MergeDiff takes a ResourceDiff and merges the attributes into this resource state in order to generate a new state. This new state can be used to provide updated attribute lookups for variable interpolation.
If the diff attribute requires computing the value, and hence won't be available until apply, the value is replaced with the computeID.
func (*InstanceState) Set ¶
func (s *InstanceState) Set(from *InstanceState)
Copy all the Fields from another InstanceState
func (*InstanceState) String ¶
func (s *InstanceState) String() string
func (*InstanceState) Unlock ¶
func (s *InstanceState) Unlock()
type InstanceType ¶
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 ¶
func ParseInstanceType(s string) (InstanceType, error)
func (InstanceType) String ¶
func (i InstanceType) String() string
type LocalTransformer ¶
LocalTransformer is a GraphTransformer that adds all the local values from the configuration to the graph.
func (*LocalTransformer) Transform ¶
func (t *LocalTransformer) Transform(g *Graph) error
type MissingProviderTransformer ¶
type MissingProviderTransformer struct { // Providers is the list of providers we support. Providers []string // Concrete, if set, overrides how the providers are made. Concrete ConcreteProviderNodeFunc }
MissingProviderTransformer is a GraphTransformer that adds to the graph a node for each default provider configuration that is referenced by another node but not already present in the graph.
These "default" nodes are always added to the root module, regardless of where they are requested. This is important because our inheritance resolution behavior in ProviderTransformer will then treat these as a last-ditch fallback after walking up the tree, rather than preferring them as it would if they were placed in the same module as the requester.
This transformer may create extra nodes that are not needed in practice, due to overriding provider configurations in child modules. PruneProviderTransformer can then remove these once ProviderTransformer has resolved all of the inheritence, etc.
func (*MissingProviderTransformer) Transform ¶
func (t *MissingProviderTransformer) Transform(g *Graph) error
type MissingProvisionerTransformer ¶
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 ¶
func (t *MissingProvisionerTransformer) Transform(g *Graph) error
type MockEvalContext ¶
type MockEvalContext struct { StoppedCalled bool StoppedValue <-chan struct{} HookCalled bool HookHook Hook HookError error InputCalled bool InputInput UIInput InitProviderCalled bool InitProviderType string InitProviderAddr addrs.ProviderConfig InitProviderProvider providers.Interface InitProviderError error ProviderCalled bool ProviderAddr addrs.AbsProviderConfig ProviderProvider providers.Interface ProviderSchemaCalled bool ProviderSchemaAddr addrs.AbsProviderConfig ProviderSchemaSchema *ProviderSchema CloseProviderCalled bool CloseProviderAddr addrs.ProviderConfig CloseProviderProvider providers.Interface ProviderInputCalled bool ProviderInputAddr addrs.ProviderConfig ProviderInputValues map[string]cty.Value SetProviderInputCalled bool SetProviderInputAddr addrs.ProviderConfig SetProviderInputValues map[string]cty.Value ConfigureProviderCalled bool ConfigureProviderAddr addrs.ProviderConfig ConfigureProviderConfig cty.Value ConfigureProviderDiags tfdiags.Diagnostics InitProvisionerCalled bool InitProvisionerName string InitProvisionerProvisioner provisioners.Interface InitProvisionerError error ProvisionerCalled bool ProvisionerName string ProvisionerProvisioner provisioners.Interface ProvisionerSchemaCalled bool ProvisionerSchemaName string ProvisionerSchemaSchema *configschema.Block CloseProvisionerCalled bool CloseProvisionerName string CloseProvisionerProvisioner provisioners.Interface EvaluateBlockCalled bool EvaluateBlockBody hcl.Body EvaluateBlockSchema *configschema.Block EvaluateBlockSelf addrs.Referenceable EvaluateBlockKeyData InstanceKeyEvalData EvaluateBlockResultFunc func( body hcl.Body, schema *configschema.Block, self addrs.Referenceable, keyData InstanceKeyEvalData, ) (cty.Value, hcl.Body, tfdiags.Diagnostics) // overrides the other values below, if set EvaluateBlockResult cty.Value EvaluateBlockExpandedBody hcl.Body EvaluateBlockDiags tfdiags.Diagnostics EvaluateExprCalled bool EvaluateExprExpr hcl.Expression EvaluateExprWantType cty.Type EvaluateExprSelf addrs.Referenceable EvaluateExprResultFunc func( expr hcl.Expression, wantType cty.Type, self addrs.Referenceable, ) (cty.Value, tfdiags.Diagnostics) // overrides the other values below, if set EvaluateExprResult cty.Value EvaluateExprDiags tfdiags.Diagnostics EvaluationScopeCalled bool EvaluationScopeSelf addrs.Referenceable EvaluationScopeKeyData InstanceKeyEvalData EvaluationScopeScope *lang.Scope PathCalled bool PathPath addrs.ModuleInstance SetModuleCallArgumentsCalled bool SetModuleCallArgumentsModule addrs.ModuleCallInstance SetModuleCallArgumentsValues map[string]cty.Value ChangesCalled bool ChangesChanges *plans.ChangesSync StateCalled bool StateState *states.SyncState }
MockEvalContext is a mock version of EvalContext that can be used for tests.
func (*MockEvalContext) Changes ¶
func (c *MockEvalContext) Changes() *plans.ChangesSync
func (*MockEvalContext) CloseProvider ¶
func (c *MockEvalContext) CloseProvider(addr addrs.ProviderConfig) error
func (*MockEvalContext) CloseProvisioner ¶
func (c *MockEvalContext) CloseProvisioner(n string) error
func (*MockEvalContext) ConfigureProvider ¶
func (c *MockEvalContext) ConfigureProvider(addr addrs.ProviderConfig, cfg cty.Value) tfdiags.Diagnostics
func (*MockEvalContext) EvaluateBlock ¶
func (c *MockEvalContext) EvaluateBlock(body hcl.Body, schema *configschema.Block, self addrs.Referenceable, keyData InstanceKeyEvalData) (cty.Value, hcl.Body, tfdiags.Diagnostics)
func (*MockEvalContext) EvaluateExpr ¶
func (c *MockEvalContext) EvaluateExpr(expr hcl.Expression, wantType cty.Type, self addrs.Referenceable) (cty.Value, tfdiags.Diagnostics)
func (*MockEvalContext) EvaluationScope ¶
func (c *MockEvalContext) EvaluationScope(self addrs.Referenceable, keyData InstanceKeyEvalData) *lang.Scope
func (*MockEvalContext) Hook ¶
func (c *MockEvalContext) Hook(fn func(Hook) (HookAction, error)) error
func (*MockEvalContext) InitProvider ¶
func (c *MockEvalContext) InitProvider(t string, addr addrs.ProviderConfig) (providers.Interface, error)
func (*MockEvalContext) InitProvisioner ¶
func (c *MockEvalContext) InitProvisioner(n string) (provisioners.Interface, error)
func (*MockEvalContext) Input ¶
func (c *MockEvalContext) Input() UIInput
func (*MockEvalContext) Path ¶
func (c *MockEvalContext) Path() addrs.ModuleInstance
func (*MockEvalContext) Provider ¶
func (c *MockEvalContext) Provider(addr addrs.AbsProviderConfig) providers.Interface
func (*MockEvalContext) ProviderInput ¶
func (c *MockEvalContext) ProviderInput(addr addrs.ProviderConfig) map[string]cty.Value
func (*MockEvalContext) ProviderSchema ¶
func (c *MockEvalContext) ProviderSchema(addr addrs.AbsProviderConfig) *ProviderSchema
func (*MockEvalContext) Provisioner ¶
func (c *MockEvalContext) Provisioner(n string) provisioners.Interface
func (*MockEvalContext) ProvisionerSchema ¶
func (c *MockEvalContext) ProvisionerSchema(n string) *configschema.Block
func (*MockEvalContext) SetModuleCallArguments ¶
func (c *MockEvalContext) SetModuleCallArguments(n addrs.ModuleCallInstance, values map[string]cty.Value)
func (*MockEvalContext) SetProviderInput ¶
func (c *MockEvalContext) SetProviderInput(addr addrs.ProviderConfig, vals map[string]cty.Value)
func (*MockEvalContext) State ¶
func (c *MockEvalContext) State() *states.SyncState
func (*MockEvalContext) Stopped ¶
func (c *MockEvalContext) Stopped() <-chan struct{}
type MockHook ¶
type MockHook struct { sync.Mutex PreApplyCalled bool PreApplyAddr addrs.AbsResourceInstance PreApplyGen states.Generation PreApplyAction plans.Action PreApplyPriorState cty.Value PreApplyPlannedState cty.Value PreApplyReturn HookAction PreApplyError error PostApplyCalled bool PostApplyAddr addrs.AbsResourceInstance PostApplyGen states.Generation PostApplyNewState cty.Value PostApplyError error PostApplyReturn HookAction PostApplyReturnError error PostApplyFn func(addrs.AbsResourceInstance, states.Generation, cty.Value, error) (HookAction, error) PreDiffCalled bool PreDiffAddr addrs.AbsResourceInstance PreDiffGen states.Generation PreDiffPriorState cty.Value PreDiffProposedState cty.Value PreDiffReturn HookAction PreDiffError error PostDiffCalled bool PostDiffAddr addrs.AbsResourceInstance PostDiffGen states.Generation PostDiffAction plans.Action PostDiffPriorState cty.Value PostDiffPlannedState cty.Value PostDiffReturn HookAction PostDiffError error PreProvisionInstanceCalled bool PreProvisionInstanceAddr addrs.AbsResourceInstance PreProvisionInstanceState cty.Value PreProvisionInstanceReturn HookAction PreProvisionInstanceError error PostProvisionInstanceCalled bool PostProvisionInstanceAddr addrs.AbsResourceInstance PostProvisionInstanceState cty.Value PostProvisionInstanceReturn HookAction PostProvisionInstanceError error PreProvisionInstanceStepCalled bool PreProvisionInstanceStepAddr addrs.AbsResourceInstance PreProvisionInstanceStepProvisionerType string PreProvisionInstanceStepReturn HookAction PreProvisionInstanceStepError error PostProvisionInstanceStepCalled bool PostProvisionInstanceStepAddr addrs.AbsResourceInstance PostProvisionInstanceStepProvisionerType string PostProvisionInstanceStepErrorArg error PostProvisionInstanceStepReturn HookAction PostProvisionInstanceStepError error ProvisionOutputCalled bool ProvisionOutputAddr addrs.AbsResourceInstance ProvisionOutputProvisionerType string ProvisionOutputMessage string PreRefreshCalled bool PreRefreshAddr addrs.AbsResourceInstance PreRefreshGen states.Generation PreRefreshPriorState cty.Value PreRefreshReturn HookAction PreRefreshError error PostRefreshCalled bool PostRefreshAddr addrs.AbsResourceInstance PostRefreshGen states.Generation PostRefreshPriorState cty.Value PostRefreshNewState cty.Value PostRefreshReturn HookAction PostRefreshError error PreImportStateCalled bool PreImportStateAddr addrs.AbsResourceInstance PreImportStateID string PreImportStateReturn HookAction PreImportStateError error PostImportStateCalled bool PostImportStateAddr addrs.AbsResourceInstance PostImportStateNewStates []providers.ImportedResource PostImportStateReturn HookAction PostImportStateError error PostStateUpdateCalled bool PostStateUpdateState *states.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(addr addrs.AbsResourceInstance, gen states.Generation, newState cty.Value, err error) (HookAction, error)
func (*MockHook) PostDiff ¶
func (h *MockHook) PostDiff(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, priorState, plannedNewState cty.Value) (HookAction, error)
func (*MockHook) PostImportState ¶
func (h *MockHook) PostImportState(addr addrs.AbsResourceInstance, imported []providers.ImportedResource) (HookAction, error)
func (*MockHook) PostProvisionInstance ¶
func (h *MockHook) PostProvisionInstance(addr addrs.AbsResourceInstance, state cty.Value) (HookAction, error)
func (*MockHook) PostProvisionInstanceStep ¶
func (h *MockHook) PostProvisionInstanceStep(addr addrs.AbsResourceInstance, typeName string, err error) (HookAction, error)
func (*MockHook) PostRefresh ¶
func (h *MockHook) PostRefresh(addr addrs.AbsResourceInstance, gen states.Generation, priorState cty.Value, newState cty.Value) (HookAction, error)
func (*MockHook) PostStateUpdate ¶
func (h *MockHook) PostStateUpdate(new *states.State) (HookAction, error)
func (*MockHook) PreApply ¶
func (h *MockHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, priorState, plannedNewState cty.Value) (HookAction, error)
func (*MockHook) PreDiff ¶
func (h *MockHook) PreDiff(addr addrs.AbsResourceInstance, gen states.Generation, priorState, proposedNewState cty.Value) (HookAction, error)
func (*MockHook) PreImportState ¶
func (h *MockHook) PreImportState(addr addrs.AbsResourceInstance, importID string) (HookAction, error)
func (*MockHook) PreProvisionInstance ¶
func (h *MockHook) PreProvisionInstance(addr addrs.AbsResourceInstance, state cty.Value) (HookAction, error)
func (*MockHook) PreProvisionInstanceStep ¶
func (h *MockHook) PreProvisionInstanceStep(addr addrs.AbsResourceInstance, typeName string) (HookAction, error)
func (*MockHook) PreRefresh ¶
func (h *MockHook) PreRefresh(addr addrs.AbsResourceInstance, gen states.Generation, priorState cty.Value) (HookAction, error)
func (*MockHook) ProvisionOutput ¶
func (h *MockHook) ProvisionOutput(addr addrs.AbsResourceInstance, typeName string, line string)
type MockProvider ¶
type MockProvider struct { sync.Mutex // Anything you want, in case you need to store extra data with the mock. Meta interface{} GetSchemaCalled bool GetSchemaReturn *ProviderSchema // This is using ProviderSchema directly rather than providers.GetSchemaResponse for compatibility with old tests PrepareProviderConfigCalled bool PrepareProviderConfigResponse providers.PrepareProviderConfigResponse PrepareProviderConfigRequest providers.PrepareProviderConfigRequest PrepareProviderConfigFn func(providers.PrepareProviderConfigRequest) providers.PrepareProviderConfigResponse ValidateResourceTypeConfigCalled bool ValidateResourceTypeConfigTypeName string ValidateResourceTypeConfigResponse providers.ValidateResourceTypeConfigResponse ValidateResourceTypeConfigRequest providers.ValidateResourceTypeConfigRequest ValidateResourceTypeConfigFn func(providers.ValidateResourceTypeConfigRequest) providers.ValidateResourceTypeConfigResponse ValidateDataSourceConfigCalled bool ValidateDataSourceConfigTypeName string ValidateDataSourceConfigResponse providers.ValidateDataSourceConfigResponse ValidateDataSourceConfigRequest providers.ValidateDataSourceConfigRequest ValidateDataSourceConfigFn func(providers.ValidateDataSourceConfigRequest) providers.ValidateDataSourceConfigResponse UpgradeResourceStateCalled bool UpgradeResourceStateTypeName string UpgradeResourceStateResponse providers.UpgradeResourceStateResponse UpgradeResourceStateRequest providers.UpgradeResourceStateRequest UpgradeResourceStateFn func(providers.UpgradeResourceStateRequest) providers.UpgradeResourceStateResponse ConfigureCalled bool ConfigureResponse providers.ConfigureResponse ConfigureRequest providers.ConfigureRequest ConfigureNewFn func(providers.ConfigureRequest) providers.ConfigureResponse // Named ConfigureNewFn so we can still have the legacy ConfigureFn declared below StopCalled bool StopFn func() error StopResponse error ReadResourceCalled bool ReadResourceResponse providers.ReadResourceResponse ReadResourceRequest providers.ReadResourceRequest ReadResourceFn func(providers.ReadResourceRequest) providers.ReadResourceResponse PlanResourceChangeCalled bool PlanResourceChangeResponse providers.PlanResourceChangeResponse PlanResourceChangeRequest providers.PlanResourceChangeRequest PlanResourceChangeFn func(providers.PlanResourceChangeRequest) providers.PlanResourceChangeResponse ApplyResourceChangeCalled bool ApplyResourceChangeResponse providers.ApplyResourceChangeResponse ApplyResourceChangeRequest providers.ApplyResourceChangeRequest ApplyResourceChangeFn func(providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse ImportResourceStateCalled bool ImportResourceStateResponse providers.ImportResourceStateResponse ImportResourceStateRequest providers.ImportResourceStateRequest ImportResourceStateFn func(providers.ImportResourceStateRequest) providers.ImportResourceStateResponse // Legacy return type for existing tests, which will be shimmed into an // ImportResourceStateResponse if set ImportStateReturn []*InstanceState ReadDataSourceCalled bool ReadDataSourceResponse providers.ReadDataSourceResponse ReadDataSourceRequest providers.ReadDataSourceRequest ReadDataSourceFn func(providers.ReadDataSourceRequest) providers.ReadDataSourceResponse CloseCalled bool CloseError error // Legacy callbacks: if these are set, we will shim incoming calls for // new-style methods to these old-fashioned terraform.ResourceProvider // mock callbacks, for the benefit of older tests that were written against // the old mock API. ValidateFn func(c *ResourceConfig) (ws []string, es []error) ConfigureFn func(c *ResourceConfig) error DiffFn func(info *InstanceInfo, s *InstanceState, c *ResourceConfig) (*InstanceDiff, error) ApplyFn func(info *InstanceInfo, s *InstanceState, d *InstanceDiff) (*InstanceState, error) }
MockProvider implements providers.Interface but mocks out all the calls for testing purposes.
func (*MockProvider) ApplyResourceChange ¶
func (p *MockProvider) ApplyResourceChange(r providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse
func (*MockProvider) Close ¶
func (p *MockProvider) Close() error
func (*MockProvider) Configure ¶
func (p *MockProvider) Configure(r providers.ConfigureRequest) providers.ConfigureResponse
func (*MockProvider) GetSchema ¶
func (p *MockProvider) GetSchema() providers.GetSchemaResponse
func (*MockProvider) ImportResourceState ¶
func (p *MockProvider) ImportResourceState(r providers.ImportResourceStateRequest) providers.ImportResourceStateResponse
func (*MockProvider) PlanResourceChange ¶
func (p *MockProvider) PlanResourceChange(r providers.PlanResourceChangeRequest) providers.PlanResourceChangeResponse
func (*MockProvider) PrepareProviderConfig ¶
func (p *MockProvider) PrepareProviderConfig(r providers.PrepareProviderConfigRequest) providers.PrepareProviderConfigResponse
func (*MockProvider) ReadDataSource ¶
func (p *MockProvider) ReadDataSource(r providers.ReadDataSourceRequest) providers.ReadDataSourceResponse
func (*MockProvider) ReadResource ¶
func (p *MockProvider) ReadResource(r providers.ReadResourceRequest) providers.ReadResourceResponse
func (*MockProvider) Stop ¶
func (p *MockProvider) Stop() error
func (*MockProvider) UpgradeResourceState ¶
func (p *MockProvider) UpgradeResourceState(r providers.UpgradeResourceStateRequest) providers.UpgradeResourceStateResponse
func (*MockProvider) ValidateDataSourceConfig ¶
func (p *MockProvider) ValidateDataSourceConfig(r providers.ValidateDataSourceConfigRequest) providers.ValidateDataSourceConfigResponse
func (*MockProvider) ValidateResourceTypeConfig ¶
func (p *MockProvider) ValidateResourceTypeConfig(r providers.ValidateResourceTypeConfigRequest) providers.ValidateResourceTypeConfigResponse
type MockProvisioner ¶
type MockProvisioner struct { sync.Mutex // Anything you want, in case you need to store extra data with the mock. Meta interface{} GetSchemaCalled bool GetSchemaResponse provisioners.GetSchemaResponse ValidateProvisionerConfigCalled bool ValidateProvisionerConfigRequest provisioners.ValidateProvisionerConfigRequest ValidateProvisionerConfigResponse provisioners.ValidateProvisionerConfigResponse ValidateProvisionerConfigFn func(provisioners.ValidateProvisionerConfigRequest) provisioners.ValidateProvisionerConfigResponse ProvisionResourceCalled bool ProvisionResourceRequest provisioners.ProvisionResourceRequest ProvisionResourceResponse provisioners.ProvisionResourceResponse ProvisionResourceFn func(provisioners.ProvisionResourceRequest) provisioners.ProvisionResourceResponse StopCalled bool StopResponse error StopFn func() error CloseCalled bool CloseResponse error CloseFn func() error // Legacy callbacks: if these are set, we will shim incoming calls for // new-style methods to these old-fashioned terraform.ResourceProvider // mock callbacks, for the benefit of older tests that were written against // the old mock API. ApplyFn func(rs *InstanceState, c *ResourceConfig) error }
MockProvisioner implements provisioners.Interface but mocks out all the calls for testing purposes.
func (*MockProvisioner) Close ¶
func (p *MockProvisioner) Close() error
func (*MockProvisioner) GetSchema ¶
func (p *MockProvisioner) GetSchema() provisioners.GetSchemaResponse
func (*MockProvisioner) ProvisionResource ¶
func (p *MockProvisioner) ProvisionResource(r provisioners.ProvisionResourceRequest) provisioners.ProvisionResourceResponse
func (*MockProvisioner) Stop ¶
func (p *MockProvisioner) Stop() error
func (*MockProvisioner) ValidateProvisionerConfig ¶
func (p *MockProvisioner) ValidateProvisionerConfig(r provisioners.ValidateProvisionerConfigRequest) provisioners.ValidateProvisionerConfigResponse
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 GetSchemaCalled bool GetSchemaRequest *ProviderSchemaRequest GetSchemaReturn *ProviderSchema GetSchemaReturnError error InputCalled bool InputInput UIInput InputConfig *ResourceConfig InputReturnConfig *ResourceConfig InputReturnError error InputFn func(UIInput, *ResourceConfig) (*ResourceConfig, error) ApplyCalled bool ApplyInfo *InstanceInfo ApplyState *InstanceState ApplyDiff *InstanceDiff ApplyFn func(*InstanceInfo, *InstanceState, *InstanceDiff) (*InstanceState, error) ApplyReturn *InstanceState ApplyReturnError error ConfigureCalled bool ConfigureConfig *ResourceConfig ConfigureFn func(*ResourceConfig) error ConfigureReturnError error DiffCalled bool DiffInfo *InstanceInfo DiffState *InstanceState DiffDesired *ResourceConfig DiffFn func(*InstanceInfo, *InstanceState, *ResourceConfig) (*InstanceDiff, error) DiffReturn *InstanceDiff DiffReturnError error RefreshCalled bool RefreshInfo *InstanceInfo RefreshState *InstanceState RefreshFn func(*InstanceInfo, *InstanceState) (*InstanceState, error) RefreshReturn *InstanceState RefreshReturnError error ResourcesCalled bool ResourcesReturn []ResourceType ReadDataApplyCalled bool ReadDataApplyInfo *InstanceInfo ReadDataApplyDiff *InstanceDiff ReadDataApplyFn func(*InstanceInfo, *InstanceDiff) (*InstanceState, error) ReadDataApplyReturn *InstanceState ReadDataApplyReturnError error ReadDataDiffCalled bool ReadDataDiffInfo *InstanceInfo ReadDataDiffDesired *ResourceConfig ReadDataDiffFn func(*InstanceInfo, *ResourceConfig) (*InstanceDiff, error) ReadDataDiffReturn *InstanceDiff ReadDataDiffReturnError error StopCalled bool StopFn func() error StopReturnError error DataSourcesCalled bool DataSourcesReturn []DataSource ValidateCalled bool ValidateConfig *ResourceConfig ValidateFn func(*ResourceConfig) ([]string, []error) ValidateReturnWarns []string ValidateReturnErrors []error ValidateResourceFn func(string, *ResourceConfig) ([]string, []error) ValidateResourceCalled bool ValidateResourceType string ValidateResourceConfig *ResourceConfig ValidateResourceReturnWarns []string ValidateResourceReturnErrors []error ValidateDataSourceFn func(string, *ResourceConfig) ([]string, []error) ValidateDataSourceCalled bool ValidateDataSourceType string ValidateDataSourceConfig *ResourceConfig ValidateDataSourceReturnWarns []string ValidateDataSourceReturnErrors []error ImportStateCalled bool ImportStateInfo *InstanceInfo ImportStateID string ImportStateReturn []*InstanceState ImportStateReturnError error ImportStateFn func(*InstanceInfo, string) ([]*InstanceState, error) }
MockResourceProvider implements ResourceProvider but mocks out all the calls for testing purposes.
func (*MockResourceProvider) Apply ¶
func (p *MockResourceProvider) Apply( info *InstanceInfo, state *InstanceState, diff *InstanceDiff) (*InstanceState, error)
func (*MockResourceProvider) Close ¶
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) GetSchema ¶
func (p *MockResourceProvider) GetSchema(req *ProviderSchemaRequest) (*ProviderSchema, error)
func (*MockResourceProvider) ImportState ¶
func (p *MockResourceProvider) ImportState(info *InstanceInfo, id string) ([]*InstanceState, error)
func (*MockResourceProvider) Input ¶
func (p *MockResourceProvider) Input( input UIInput, c *ResourceConfig) (*ResourceConfig, error)
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 (p *MockResourceProvider) Refresh( info *InstanceInfo, s *InstanceState) (*InstanceState, error)
func (*MockResourceProvider) Resources ¶
func (p *MockResourceProvider) Resources() []ResourceType
func (*MockResourceProvider) Stop ¶
func (p *MockResourceProvider) Stop() error
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 { sync.Mutex // Anything you want, in case you need to store extra data with the mock. Meta interface{} GetConfigSchemaCalled bool GetConfigSchemaReturnSchema *configschema.Block GetConfigSchemaReturnError error ApplyCalled bool ApplyOutput UIOutput ApplyState *InstanceState ApplyConfig *ResourceConfig ApplyFn func(*InstanceState, *ResourceConfig) error ApplyReturnError error ValidateCalled bool ValidateConfig *ResourceConfig ValidateFn func(c *ResourceConfig) ([]string, []error) ValidateReturnWarns []string ValidateReturnErrors []error StopCalled bool StopFn func() error StopReturnError error }
MockResourceProvisioner implements ResourceProvisioner but mocks out all the calls for testing purposes.
func (*MockResourceProvisioner) Apply ¶
func (p *MockResourceProvisioner) Apply( output UIOutput, state *InstanceState, c *ResourceConfig) error
func (*MockResourceProvisioner) GetConfigSchema ¶
func (p *MockResourceProvisioner) GetConfigSchema() (*configschema.Block, error)
func (*MockResourceProvisioner) Stop ¶
func (p *MockResourceProvisioner) Stop() error
func (*MockResourceProvisioner) Validate ¶
func (p *MockResourceProvisioner) Validate(c *ResourceConfig) ([]string, []error)
type MockUIInput ¶
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.
type MockUIOutput ¶
type MockUIOutput struct { sync.Mutex OutputCalled bool OutputMessage string OutputFn func(string) }
MockUIOutput is an implementation of UIOutput that can be used for tests.
func (*MockUIOutput) Output ¶
func (o *MockUIOutput) Output(v string)
type ModuleDiff ¶
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 ¶
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 ¶
func (d *ModuleDiff) Empty() bool
Empty returns true if the diff has no changes within this module.
func (*ModuleDiff) Instances ¶
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 ¶
func (d *ModuleDiff) IsRoot() bool
IsRoot says whether or not this module diff is for the root module.
func (*ModuleDiff) String ¶
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 ¶
type ModuleState struct { // Path is the import path from the root module. Modules imports are // always disjoint, so the path represents amodule tree Path []string `json:"path"` // Locals are kept only transiently in-memory, because we can always // re-compute them. Locals map[string]interface{} `json:"-"` // Outputs declared by the module and maintained for each module // even though only the root module technically needs to be kept. // This allows operators to inspect values at the boundaries. Outputs map[string]*OutputState `json:"outputs"` // Resources is a mapping of the logically named resource to // the state of the resource. Each resource may actually have // N instances underneath, although a user only needs to think // about the 1:1 case. Resources map[string]*ResourceState `json:"resources"` // Dependencies are a list of things that this module relies on // existing to remain intact. For example: an module may depend // on a VPC ID given by an aws_vpc resource. // // Terraform uses this information to build valid destruction // orders and to warn the user if they're destroying a module that // another resource depends on. // // Things can be put into this list that may not be managed by // Terraform. If Terraform doesn't find a matching ID in the // overall state, then it assumes it isn't managed and doesn't // worry about it. Dependencies []string `json:"depends_on"` // contains filtered or unexported fields }
ModuleState is used to track all the state relevant to a single module. Previous to Terraform 0.3, all state belonged to the "root" module.
func (*ModuleState) Empty ¶
func (m *ModuleState) Empty() bool
func (*ModuleState) Equal ¶
func (m *ModuleState) Equal(other *ModuleState) bool
Equal tests whether one module state is equal to another.
func (*ModuleState) IsDescendent ¶
func (m *ModuleState) IsDescendent(other *ModuleState) bool
IsDescendent returns true if other is a descendent of this module.
func (*ModuleState) IsRoot ¶
func (m *ModuleState) IsRoot() bool
IsRoot says whether or not this module diff is for the root module.
func (*ModuleState) Lock ¶
func (s *ModuleState) Lock()
func (*ModuleState) Orphans ¶
func (m *ModuleState) Orphans(c *configs.Module) []addrs.ResourceInstance
Orphans returns a list of keys of resources that are in the State but aren't present in the configuration itself. Hence, these keys represent the state of resources that are orphans.
func (*ModuleState) RemovedOutputs ¶
func (s *ModuleState) RemovedOutputs(outputs map[string]*configs.Output) []addrs.OutputValue
RemovedOutputs returns a list of outputs that are in the State but aren't present in the configuration itself.
func (*ModuleState) String ¶
func (m *ModuleState) String() string
func (*ModuleState) Unlock ¶
func (s *ModuleState) Unlock()
func (*ModuleState) View ¶
func (m *ModuleState) View(id string) *ModuleState
View returns a view with the given resource prefix.
type ModuleVariableTransformer ¶
ModuleVariableTransformer is a GraphTransformer that adds all the variables in the configuration to the graph.
Any "variable" block present in any non-root module is included here, even if a particular variable is not referenced from anywhere.
The transform will produce errors if a call to a module does not conform to the expected set of arguments, but this transformer is not in a good position to return errors and so the validate walk should include specific steps for validating module blocks, separate from this transform.
func (*ModuleVariableTransformer) Transform ¶
func (t *ModuleVariableTransformer) Transform(g *Graph) error