aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/terraform/terraform/context.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/terraform/context.go')
-rw-r--r--vendor/github.com/hashicorp/terraform/terraform/context.go32
1 files changed, 29 insertions, 3 deletions
diff --git a/vendor/github.com/hashicorp/terraform/terraform/context.go b/vendor/github.com/hashicorp/terraform/terraform/context.go
index 306128e..a814a85 100644
--- a/vendor/github.com/hashicorp/terraform/terraform/context.go
+++ b/vendor/github.com/hashicorp/terraform/terraform/context.go
@@ -57,12 +57,17 @@ type ContextOpts struct {
57 Parallelism int 57 Parallelism int
58 State *State 58 State *State
59 StateFutureAllowed bool 59 StateFutureAllowed bool
60 Providers map[string]ResourceProviderFactory 60 ProviderResolver ResourceProviderResolver
61 Provisioners map[string]ResourceProvisionerFactory 61 Provisioners map[string]ResourceProvisionerFactory
62 Shadow bool 62 Shadow bool
63 Targets []string 63 Targets []string
64 Variables map[string]interface{} 64 Variables map[string]interface{}
65 65
66 // If non-nil, will apply as additional constraints on the provider
67 // plugins that will be requested from the provider resolver.
68 ProviderSHA256s map[string][]byte
69 SkipProviderVerify bool
70
66 UIInput UIInput 71 UIInput UIInput
67} 72}
68 73
@@ -102,6 +107,7 @@ type Context struct {
102 l sync.Mutex // Lock acquired during any task 107 l sync.Mutex // Lock acquired during any task
103 parallelSem Semaphore 108 parallelSem Semaphore
104 providerInputConfig map[string]map[string]interface{} 109 providerInputConfig map[string]map[string]interface{}
110 providerSHA256s map[string][]byte
105 runLock sync.Mutex 111 runLock sync.Mutex
106 runCond *sync.Cond 112 runCond *sync.Cond
107 runContext context.Context 113 runContext context.Context
@@ -166,7 +172,6 @@ func NewContext(opts *ContextOpts) (*Context, error) {
166 // set by environment variables if necessary. This includes 172 // set by environment variables if necessary. This includes
167 // values taken from -var-file in addition. 173 // values taken from -var-file in addition.
168 variables := make(map[string]interface{}) 174 variables := make(map[string]interface{})
169
170 if opts.Module != nil { 175 if opts.Module != nil {
171 var err error 176 var err error
172 variables, err = Variables(opts.Module, opts.Variables) 177 variables, err = Variables(opts.Module, opts.Variables)
@@ -175,6 +180,23 @@ func NewContext(opts *ContextOpts) (*Context, error) {
175 } 180 }
176 } 181 }
177 182
183 // Bind available provider plugins to the constraints in config
184 var providers map[string]ResourceProviderFactory
185 if opts.ProviderResolver != nil {
186 var err error
187 deps := ModuleTreeDependencies(opts.Module, state)
188 reqd := deps.AllPluginRequirements()
189 if opts.ProviderSHA256s != nil && !opts.SkipProviderVerify {
190 reqd.LockExecutables(opts.ProviderSHA256s)
191 }
192 providers, err = resourceProviderFactories(opts.ProviderResolver, reqd)
193 if err != nil {
194 return nil, err
195 }
196 } else {
197 providers = make(map[string]ResourceProviderFactory)
198 }
199
178 diff := opts.Diff 200 diff := opts.Diff
179 if diff == nil { 201 if diff == nil {
180 diff = &Diff{} 202 diff = &Diff{}
@@ -182,7 +204,7 @@ func NewContext(opts *ContextOpts) (*Context, error) {
182 204
183 return &Context{ 205 return &Context{
184 components: &basicComponentFactory{ 206 components: &basicComponentFactory{
185 providers: opts.Providers, 207 providers: providers,
186 provisioners: opts.Provisioners, 208 provisioners: opts.Provisioners,
187 }, 209 },
188 destroy: opts.Destroy, 210 destroy: opts.Destroy,
@@ -198,6 +220,7 @@ func NewContext(opts *ContextOpts) (*Context, error) {
198 220
199 parallelSem: NewSemaphore(par), 221 parallelSem: NewSemaphore(par),
200 providerInputConfig: make(map[string]map[string]interface{}), 222 providerInputConfig: make(map[string]map[string]interface{}),
223 providerSHA256s: opts.ProviderSHA256s,
201 sh: sh, 224 sh: sh,
202 }, nil 225 }, nil
203} 226}
@@ -509,6 +532,9 @@ func (c *Context) Plan() (*Plan, error) {
509 Vars: c.variables, 532 Vars: c.variables,
510 State: c.state, 533 State: c.state,
511 Targets: c.targets, 534 Targets: c.targets,
535
536 TerraformVersion: VersionString(),
537 ProviderSHA256s: c.providerSHA256s,
512 } 538 }
513 539
514 var operation walkOperation 540 var operation walkOperation