]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - vendor/github.com/hashicorp/terraform/terraform/eval_context.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / terraform / terraform / eval_context.go
CommitLineData
bae9f6d2
JC
1package terraform
2
3import (
107c1cdb
ND
4 "github.com/hashicorp/hcl2/hcl"
5 "github.com/hashicorp/terraform/addrs"
6 "github.com/hashicorp/terraform/configs/configschema"
7 "github.com/hashicorp/terraform/lang"
8 "github.com/hashicorp/terraform/plans"
9 "github.com/hashicorp/terraform/providers"
10 "github.com/hashicorp/terraform/provisioners"
11 "github.com/hashicorp/terraform/states"
12 "github.com/hashicorp/terraform/tfdiags"
13 "github.com/zclconf/go-cty/cty"
bae9f6d2
JC
14)
15
16// EvalContext is the interface that is given to eval nodes to execute.
17type EvalContext interface {
18 // Stopped returns a channel that is closed when evaluation is stopped
19 // via Terraform.Context.Stop()
20 Stopped() <-chan struct{}
21
22 // Path is the current module path.
107c1cdb 23 Path() addrs.ModuleInstance
bae9f6d2
JC
24
25 // Hook is used to call hook methods. The callback is called for each
26 // hook and should return the hook action to take and the error.
27 Hook(func(Hook) (HookAction, error)) error
28
29 // Input is the UIInput object for interacting with the UI.
30 Input() UIInput
31
107c1cdb 32 // InitProvider initializes the provider with the given type and address, and
bae9f6d2
JC
33 // returns the implementation of the resource provider or an error.
34 //
35 // It is an error to initialize the same provider more than once.
107c1cdb 36 InitProvider(typ string, addr addrs.ProviderConfig) (providers.Interface, error)
bae9f6d2 37
107c1cdb 38 // Provider gets the provider instance with the given address (already
bae9f6d2 39 // initialized) or returns nil if the provider isn't initialized.
107c1cdb
ND
40 //
41 // This method expects an _absolute_ provider configuration address, since
42 // resources in one module are able to use providers from other modules.
43 // InitProvider must've been called on the EvalContext of the module
44 // that owns the given provider before calling this method.
45 Provider(addrs.AbsProviderConfig) providers.Interface
46
47 // ProviderSchema retrieves the schema for a particular provider, which
48 // must have already been initialized with InitProvider.
49 //
50 // This method expects an _absolute_ provider configuration address, since
51 // resources in one module are able to use providers from other modules.
52 ProviderSchema(addrs.AbsProviderConfig) *ProviderSchema
bae9f6d2
JC
53
54 // CloseProvider closes provider connections that aren't needed anymore.
107c1cdb 55 CloseProvider(addrs.ProviderConfig) error
bae9f6d2
JC
56
57 // ConfigureProvider configures the provider with the given
58 // configuration. This is a separate context call because this call
59 // is used to store the provider configuration for inheritance lookups
60 // with ParentProviderConfig().
107c1cdb 61 ConfigureProvider(addrs.ProviderConfig, cty.Value) tfdiags.Diagnostics
bae9f6d2
JC
62
63 // ProviderInput and SetProviderInput are used to configure providers
64 // from user input.
107c1cdb
ND
65 ProviderInput(addrs.ProviderConfig) map[string]cty.Value
66 SetProviderInput(addrs.ProviderConfig, map[string]cty.Value)
bae9f6d2
JC
67
68 // InitProvisioner initializes the provisioner with the given name and
69 // returns the implementation of the resource provisioner or an error.
70 //
71 // It is an error to initialize the same provisioner more than once.
107c1cdb 72 InitProvisioner(string) (provisioners.Interface, error)
bae9f6d2
JC
73
74 // Provisioner gets the provisioner instance with the given name (already
75 // initialized) or returns nil if the provisioner isn't initialized.
107c1cdb
ND
76 Provisioner(string) provisioners.Interface
77
78 // ProvisionerSchema retrieves the main configuration schema for a
79 // particular provisioner, which must have already been initialized with
80 // InitProvisioner.
81 ProvisionerSchema(string) *configschema.Block
bae9f6d2
JC
82
83 // CloseProvisioner closes provisioner connections that aren't needed
84 // anymore.
85 CloseProvisioner(string) error
86
107c1cdb
ND
87 // EvaluateBlock takes the given raw configuration block and associated
88 // schema and evaluates it to produce a value of an object type that
89 // conforms to the implied type of the schema.
90 //
91 // The "self" argument is optional. If given, it is the referenceable
92 // address that the name "self" should behave as an alias for when
93 // evaluating. Set this to nil if the "self" object should not be available.
94 //
95 // The "key" argument is also optional. If given, it is the instance key
96 // of the current object within the multi-instance container it belongs
97 // to. For example, on a resource block with "count" set this should be
98 // set to a different addrs.IntKey for each instance created from that
99 // block. Set this to addrs.NoKey if not appropriate.
100 //
101 // The returned body is an expanded version of the given body, with any
102 // "dynamic" blocks replaced with zero or more static blocks. This can be
103 // used to extract correct source location information about attributes of
104 // the returned object value.
105 EvaluateBlock(body hcl.Body, schema *configschema.Block, self addrs.Referenceable, keyData InstanceKeyEvalData) (cty.Value, hcl.Body, tfdiags.Diagnostics)
106
107 // EvaluateExpr takes the given HCL expression and evaluates it to produce
108 // a value.
109 //
110 // The "self" argument is optional. If given, it is the referenceable
111 // address that the name "self" should behave as an alias for when
112 // evaluating. Set this to nil if the "self" object should not be available.
113 EvaluateExpr(expr hcl.Expression, wantType cty.Type, self addrs.Referenceable) (cty.Value, tfdiags.Diagnostics)
114
115 // EvaluationScope returns a scope that can be used to evaluate reference
116 // addresses in this context.
117 EvaluationScope(self addrs.Referenceable, keyData InstanceKeyEvalData) *lang.Scope
118
119 // SetModuleCallArguments defines values for the variables of a particular
120 // child module call.
bae9f6d2 121 //
107c1cdb
ND
122 // Calling this function multiple times has merging behavior, keeping any
123 // previously-set keys that are not present in the new map.
124 SetModuleCallArguments(addrs.ModuleCallInstance, map[string]cty.Value)
125
126 // Changes returns the writer object that can be used to write new proposed
127 // changes into the global changes set.
128 Changes() *plans.ChangesSync
129
130 // State returns a wrapper object that provides safe concurrent access to
131 // the global state.
132 State() *states.SyncState
bae9f6d2 133}