2015-02-07 15:29:55 -06:00
|
|
|
package terraform
|
|
|
|
|
|
|
|
import (
|
2016-12-22 13:33:26 -06:00
|
|
|
"context"
|
2015-10-14 12:43:51 -05:00
|
|
|
"log"
|
2015-02-07 15:29:55 -06:00
|
|
|
"sync"
|
|
|
|
|
2018-05-03 20:25:16 -05:00
|
|
|
"github.com/zclconf/go-cty/cty"
|
|
|
|
|
2018-07-05 12:33:29 -05:00
|
|
|
"github.com/hashicorp/terraform/configs/configschema"
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
"github.com/hashicorp/terraform/tfdiags"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/addrs"
|
|
|
|
|
2015-02-07 15:29:55 -06:00
|
|
|
"github.com/hashicorp/terraform/dag"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ContextGraphWalker is the GraphWalker implementation used with the
|
|
|
|
// Context struct to walk and evaluate the graph.
|
|
|
|
type ContextGraphWalker struct {
|
|
|
|
NullGraphWalker
|
|
|
|
|
2015-02-07 17:14:34 -06:00
|
|
|
// Configurable values
|
2018-05-03 20:25:16 -05:00
|
|
|
Context *Context
|
|
|
|
Operation walkOperation
|
|
|
|
StopContext context.Context
|
|
|
|
RootVariableValues InputValues
|
2015-02-07 15:29:55 -06:00
|
|
|
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
// This is an output. Do not set this, nor read it while a graph walk
|
|
|
|
// is in progress.
|
|
|
|
NonFatalDiagnostics tfdiags.Diagnostics
|
2015-02-07 17:14:34 -06:00
|
|
|
|
2018-05-03 20:25:16 -05:00
|
|
|
errorLock sync.Mutex
|
|
|
|
once sync.Once
|
|
|
|
contexts map[string]*BuiltinEvalContext
|
|
|
|
contextLock sync.Mutex
|
|
|
|
variableValues map[string]map[string]cty.Value
|
|
|
|
variableValuesLock sync.Mutex
|
|
|
|
providerCache map[string]ResourceProvider
|
|
|
|
providerSchemas map[string]*ProviderSchema
|
|
|
|
providerLock sync.Mutex
|
|
|
|
provisionerCache map[string]ResourceProvisioner
|
|
|
|
provisionerSchemas map[string]*configschema.Block
|
|
|
|
provisionerLock sync.Mutex
|
2015-02-07 15:29:55 -06:00
|
|
|
}
|
|
|
|
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
func (w *ContextGraphWalker) EnterPath(path addrs.ModuleInstance) EvalContext {
|
2015-02-08 19:58:02 -06:00
|
|
|
w.once.Do(w.init)
|
|
|
|
|
2015-02-11 19:01:08 -06:00
|
|
|
w.contextLock.Lock()
|
|
|
|
defer w.contextLock.Unlock()
|
|
|
|
|
|
|
|
// If we already have a context for this path cached, use that
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
key := path.String()
|
2015-02-11 19:01:08 -06:00
|
|
|
if ctx, ok := w.contexts[key]; ok {
|
|
|
|
return ctx
|
|
|
|
}
|
|
|
|
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
// Our evaluator shares some locks with the main context and the walker
|
|
|
|
// so that we can safely run multiple evaluations at once across
|
|
|
|
// different modules.
|
|
|
|
evaluator := &Evaluator{
|
2018-05-03 20:25:16 -05:00
|
|
|
Meta: w.Context.meta,
|
|
|
|
Config: w.Context.config,
|
2018-05-22 21:01:27 -05:00
|
|
|
Operation: w.Operation,
|
2018-05-03 20:25:16 -05:00
|
|
|
State: w.Context.state,
|
|
|
|
StateLock: &w.Context.stateLock,
|
2018-06-01 14:36:55 -05:00
|
|
|
Schemas: w.Context.schemas,
|
2018-05-03 20:25:16 -05:00
|
|
|
VariableValues: w.variableValues,
|
|
|
|
VariableValuesLock: &w.variableValuesLock,
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
}
|
|
|
|
|
2015-02-11 19:01:08 -06:00
|
|
|
ctx := &BuiltinEvalContext{
|
2017-11-07 09:15:11 -06:00
|
|
|
StopContext: w.StopContext,
|
|
|
|
PathValue: path,
|
|
|
|
Hooks: w.Context.hooks,
|
|
|
|
InputValue: w.Context.uiInput,
|
|
|
|
Components: w.Context.components,
|
2018-06-01 14:36:55 -05:00
|
|
|
Schemas: w.Context.schemas,
|
2017-11-07 09:15:11 -06:00
|
|
|
ProviderCache: w.providerCache,
|
2015-02-13 19:59:54 -06:00
|
|
|
ProviderInputConfig: w.Context.providerInputConfig,
|
2015-02-10 01:32:28 -06:00
|
|
|
ProviderLock: &w.providerLock,
|
|
|
|
ProvisionerCache: w.provisionerCache,
|
|
|
|
ProvisionerLock: &w.provisionerLock,
|
2015-02-12 21:34:21 -06:00
|
|
|
DiffValue: w.Context.diff,
|
|
|
|
DiffLock: &w.Context.diffLock,
|
2015-02-11 10:48:45 -06:00
|
|
|
StateValue: w.Context.state,
|
|
|
|
StateLock: &w.Context.stateLock,
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
Evaluator: evaluator,
|
2018-05-03 20:25:16 -05:00
|
|
|
VariableValues: w.variableValues,
|
|
|
|
VariableValuesLock: &w.variableValuesLock,
|
2015-02-07 15:29:55 -06:00
|
|
|
}
|
2015-02-11 19:01:08 -06:00
|
|
|
|
|
|
|
w.contexts[key] = ctx
|
|
|
|
return ctx
|
2015-02-07 15:29:55 -06:00
|
|
|
}
|
|
|
|
|
2015-02-10 10:58:14 -06:00
|
|
|
func (w *ContextGraphWalker) EnterEvalTree(v dag.Vertex, n EvalNode) EvalNode {
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
log.Printf("[TRACE] [%s] Entering eval tree: %s", w.Operation, dag.VertexName(v))
|
2015-10-14 12:43:51 -05:00
|
|
|
|
2015-02-16 22:27:29 -06:00
|
|
|
// Acquire a lock on the semaphore
|
|
|
|
w.Context.parallelSem.Acquire()
|
|
|
|
|
2015-02-10 10:58:14 -06:00
|
|
|
// We want to filter the evaluation tree to only include operations
|
|
|
|
// that belong in this operation.
|
|
|
|
return EvalFilter(n, EvalNodeFilterOp(w.Operation))
|
|
|
|
}
|
|
|
|
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
func (w *ContextGraphWalker) ExitEvalTree(v dag.Vertex, output interface{}, err error) tfdiags.Diagnostics {
|
|
|
|
log.Printf("[TRACE] [%s] Exiting eval tree: %s", w.Operation, dag.VertexName(v))
|
2015-10-14 12:43:51 -05:00
|
|
|
|
2015-02-16 22:27:29 -06:00
|
|
|
// Release the semaphore
|
|
|
|
w.Context.parallelSem.Release()
|
|
|
|
|
2015-02-07 15:29:55 -06:00
|
|
|
if err == nil {
|
2015-02-11 20:00:22 -06:00
|
|
|
return nil
|
2015-02-07 15:29:55 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Acquire the lock because anything is going to require a lock.
|
2015-02-07 17:14:34 -06:00
|
|
|
w.errorLock.Lock()
|
|
|
|
defer w.errorLock.Unlock()
|
2015-02-07 15:29:55 -06:00
|
|
|
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
// If the error is non-fatal then we'll accumulate its diagnostics in our
|
|
|
|
// non-fatal list, rather than returning it directly, so that the graph
|
|
|
|
// walk can continue.
|
|
|
|
if nferr, ok := err.(tfdiags.NonFatalError); ok {
|
2018-05-29 13:47:49 -05:00
|
|
|
log.Printf("[WARN] %s: %s", dag.VertexName(v), nferr)
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
w.NonFatalDiagnostics = w.NonFatalDiagnostics.Append(nferr.Diagnostics)
|
|
|
|
return nil
|
2015-02-16 21:11:23 -06:00
|
|
|
}
|
|
|
|
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
// Otherwise, we'll let our usual diagnostics machinery figure out how to
|
|
|
|
// unpack this as one or more diagnostic messages and return that. If we
|
|
|
|
// get down here then the returned diagnostics will contain at least one
|
|
|
|
// error, causing the graph walk to halt.
|
|
|
|
var diags tfdiags.Diagnostics
|
|
|
|
diags = diags.Append(err)
|
|
|
|
return diags
|
2015-02-07 15:29:55 -06:00
|
|
|
}
|
2015-02-08 19:58:02 -06:00
|
|
|
|
|
|
|
func (w *ContextGraphWalker) init() {
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
w.contexts = make(map[string]*BuiltinEvalContext)
|
|
|
|
w.providerCache = make(map[string]ResourceProvider)
|
|
|
|
w.providerSchemas = make(map[string]*ProviderSchema)
|
|
|
|
w.provisionerCache = make(map[string]ResourceProvisioner)
|
|
|
|
w.provisionerSchemas = make(map[string]*configschema.Block)
|
2018-05-03 20:25:16 -05:00
|
|
|
w.variableValues = make(map[string]map[string]cty.Value)
|
|
|
|
|
|
|
|
// Populate root module variable values. Other modules will be populated
|
|
|
|
// during the graph walk.
|
|
|
|
w.variableValues[""] = make(map[string]cty.Value)
|
|
|
|
for k, iv := range w.RootVariableValues {
|
|
|
|
w.variableValues[""][k] = iv.Value
|
|
|
|
}
|
2015-02-08 19:58:02 -06:00
|
|
|
}
|