2016-11-06 01:00:05 -06:00
|
|
|
package terraform
|
|
|
|
|
2016-11-06 12:15:09 -06:00
|
|
|
import (
|
2018-09-19 20:30:16 -05:00
|
|
|
"log"
|
|
|
|
|
2016-11-06 12:15:09 -06:00
|
|
|
"github.com/hashicorp/terraform/dag"
|
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"
|
2016-11-06 12:15:09 -06:00
|
|
|
)
|
|
|
|
|
2016-11-06 01:00:05 -06:00
|
|
|
// NodePlannableResource represents a resource that is "plannable":
|
|
|
|
// it is ready to be planned in order to create a diff.
|
|
|
|
type NodePlannableResource struct {
|
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
|
|
|
*NodeAbstractResource
|
2018-09-21 19:08:52 -05:00
|
|
|
|
|
|
|
// ForceCreateBeforeDestroy might be set via our GraphNodeDestroyerCBD
|
|
|
|
// during graph construction, if dependencies require us to force this
|
|
|
|
// on regardless of what the configuration says.
|
|
|
|
ForceCreateBeforeDestroy *bool
|
2016-11-06 01:00:05 -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
|
|
|
var (
|
|
|
|
_ GraphNodeSubPath = (*NodePlannableResource)(nil)
|
2018-09-21 19:08:52 -05:00
|
|
|
_ GraphNodeDestroyerCBD = (*NodePlannableResource)(nil)
|
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
|
|
|
_ GraphNodeDynamicExpandable = (*NodePlannableResource)(nil)
|
|
|
|
_ GraphNodeReferenceable = (*NodePlannableResource)(nil)
|
|
|
|
_ GraphNodeReferencer = (*NodePlannableResource)(nil)
|
|
|
|
_ GraphNodeResource = (*NodePlannableResource)(nil)
|
|
|
|
_ GraphNodeAttachResourceConfig = (*NodePlannableResource)(nil)
|
|
|
|
)
|
|
|
|
|
2018-09-19 20:30:16 -05:00
|
|
|
// GraphNodeEvalable
|
|
|
|
func (n *NodePlannableResource) EvalTree() EvalNode {
|
|
|
|
addr := n.ResourceAddr()
|
|
|
|
config := n.Config
|
|
|
|
|
|
|
|
if config == nil {
|
|
|
|
// Nothing to do, then.
|
|
|
|
log.Printf("[TRACE] NodeApplyableResource: no configuration present for %s", addr)
|
|
|
|
return &EvalNoop{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// this ensures we can reference the resource even if the count is 0
|
|
|
|
return &EvalWriteResourceState{
|
|
|
|
Addr: addr.Resource,
|
|
|
|
Config: config,
|
|
|
|
ProviderAddr: n.ResolvedProvider,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-21 19:08:52 -05:00
|
|
|
// GraphNodeDestroyerCBD
|
|
|
|
func (n *NodePlannableResource) CreateBeforeDestroy() bool {
|
|
|
|
if n.ForceCreateBeforeDestroy != nil {
|
|
|
|
return *n.ForceCreateBeforeDestroy
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we have no config, we just assume no
|
|
|
|
if n.Config == nil || n.Config.Managed == nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return n.Config.Managed.CreateBeforeDestroy
|
|
|
|
}
|
|
|
|
|
|
|
|
// GraphNodeDestroyerCBD
|
|
|
|
func (n *NodePlannableResource) ModifyCreateBeforeDestroy(v bool) error {
|
|
|
|
n.ForceCreateBeforeDestroy = &v
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-11-06 12:07:17 -06:00
|
|
|
// GraphNodeDynamicExpandable
|
|
|
|
func (n *NodePlannableResource) DynamicExpand(ctx EvalContext) (*Graph, error) {
|
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
|
|
|
var diags tfdiags.Diagnostics
|
|
|
|
|
|
|
|
count, countDiags := evaluateResourceCountExpression(n.Config.Count, ctx)
|
|
|
|
diags = diags.Append(countDiags)
|
|
|
|
if countDiags.HasErrors() {
|
|
|
|
return nil, diags.Err()
|
|
|
|
}
|
|
|
|
|
2019-06-12 10:07:32 -05:00
|
|
|
forEachMap, forEachDiags := evaluateResourceForEachExpression(n.Config.ForEach, ctx)
|
|
|
|
if forEachDiags.HasErrors() {
|
|
|
|
return nil, diags.Err()
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// Next we need to potentially rename an instance address in the state
|
|
|
|
// if we're transitioning whether "count" is set at all.
|
2018-08-27 14:03:20 -05:00
|
|
|
fixResourceCountSetTransition(ctx, n.ResourceAddr(), count != -1)
|
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
|
|
|
|
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 16:24:45 -05:00
|
|
|
// Our graph transformers require access to the full state, so we'll
|
|
|
|
// temporarily lock it while we work on this.
|
|
|
|
state := ctx.State().Lock()
|
|
|
|
defer ctx.State().Unlock()
|
2016-11-07 15:23:06 -06:00
|
|
|
|
2016-11-06 12:15:09 -06:00
|
|
|
// The concrete resource factory we'll use
|
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
|
|
|
concreteResource := func(a *NodeAbstractResourceInstance) dag.Vertex {
|
2016-11-06 12:15:09 -06:00
|
|
|
// Add the config and state since we don't do that via transforms
|
|
|
|
a.Config = n.Config
|
2017-11-01 17:34:18 -05:00
|
|
|
a.ResolvedProvider = n.ResolvedProvider
|
2018-05-31 14:39:45 -05:00
|
|
|
a.Schema = n.Schema
|
2018-06-01 17:04:28 -05:00
|
|
|
a.ProvisionerSchemas = n.ProvisionerSchemas
|
2016-11-06 12:15:09 -06:00
|
|
|
|
|
|
|
return &NodePlannableResourceInstance{
|
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
|
|
|
NodeAbstractResourceInstance: a,
|
2018-09-21 19:08:52 -05:00
|
|
|
|
|
|
|
// By the time we're walking, we've figured out whether we need
|
|
|
|
// to force on CreateBeforeDestroy due to dependencies on other
|
|
|
|
// nodes that have it.
|
|
|
|
ForceCreateBeforeDestroy: n.CreateBeforeDestroy(),
|
2016-11-06 12:15:09 -06:00
|
|
|
}
|
|
|
|
}
|
2016-11-06 12:07:17 -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
|
|
|
// The concrete resource factory we'll use for orphans
|
|
|
|
concreteResourceOrphan := func(a *NodeAbstractResourceInstance) dag.Vertex {
|
2016-11-07 16:05:21 -06:00
|
|
|
// Add the config and state since we don't do that via transforms
|
|
|
|
a.Config = n.Config
|
2017-11-01 17:34:18 -05:00
|
|
|
a.ResolvedProvider = n.ResolvedProvider
|
2018-05-31 14:39:45 -05:00
|
|
|
a.Schema = n.Schema
|
2018-06-01 17:04:28 -05:00
|
|
|
a.ProvisionerSchemas = n.ProvisionerSchemas
|
2016-11-07 16:05:21 -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
|
|
|
return &NodePlannableResourceInstanceOrphan{
|
|
|
|
NodeAbstractResourceInstance: a,
|
2016-11-07 15:23:06 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-06 12:07:17 -06:00
|
|
|
// Start creating the steps
|
2016-11-07 15:23:06 -06:00
|
|
|
steps := []GraphTransformer{
|
2019-06-12 10:07:32 -05:00
|
|
|
// Expand the count or for_each (if present)
|
2016-11-07 15:23:06 -06:00
|
|
|
&ResourceCountTransformer{
|
|
|
|
Concrete: concreteResource,
|
2018-05-02 22:16:22 -05:00
|
|
|
Schema: n.Schema,
|
2016-11-07 15:23:06 -06:00
|
|
|
Count: count,
|
2019-06-12 10:07:32 -05:00
|
|
|
ForEach: forEachMap,
|
2016-11-07 15:23:06 -06:00
|
|
|
Addr: n.ResourceAddr(),
|
|
|
|
},
|
|
|
|
|
2019-06-12 10:07:32 -05:00
|
|
|
// Add the count/for_each orphans
|
2016-11-07 15:23:06 -06:00
|
|
|
&OrphanResourceCountTransformer{
|
|
|
|
Concrete: concreteResourceOrphan,
|
|
|
|
Count: count,
|
2019-06-12 10:07:32 -05:00
|
|
|
ForEach: forEachMap,
|
2016-11-07 15:23:06 -06:00
|
|
|
Addr: n.ResourceAddr(),
|
|
|
|
State: state,
|
|
|
|
},
|
2016-11-06 12:07:17 -06:00
|
|
|
|
2016-11-07 15:23:06 -06:00
|
|
|
// Attach the state
|
|
|
|
&AttachStateTransformer{State: state},
|
|
|
|
|
2016-11-07 19:45:08 -06:00
|
|
|
// Targeting
|
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
|
|
|
&TargetsTransformer{Targets: n.Targets},
|
2016-11-07 19:45:08 -06:00
|
|
|
|
2016-11-07 15:55:35 -06:00
|
|
|
// Connect references so ordering is correct
|
|
|
|
&ReferenceTransformer{},
|
|
|
|
|
2016-11-07 15:23:06 -06:00
|
|
|
// Make sure there is a single root
|
|
|
|
&RootTransformer{},
|
|
|
|
}
|
2016-11-06 12:07:17 -06:00
|
|
|
|
|
|
|
// Build the graph
|
2016-11-15 15:36:10 -06:00
|
|
|
b := &BasicGraphBuilder{
|
|
|
|
Steps: steps,
|
|
|
|
Validate: true,
|
|
|
|
Name: "NodePlannableResource",
|
|
|
|
}
|
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
|
|
|
graph, diags := b.Build(ctx.Path())
|
|
|
|
return graph, diags.ErrWithWarnings()
|
2016-11-06 01:00:05 -06:00
|
|
|
}
|