2016-11-05 18:26:12 -05:00
|
|
|
package terraform
|
|
|
|
|
|
|
|
import (
|
2017-01-25 14:24:48 -06:00
|
|
|
"sync"
|
|
|
|
|
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/addrs"
|
|
|
|
"github.com/hashicorp/terraform/configs"
|
2016-11-05 18:26:12 -05:00
|
|
|
"github.com/hashicorp/terraform/dag"
|
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
|
|
|
"github.com/hashicorp/terraform/states"
|
|
|
|
"github.com/hashicorp/terraform/tfdiags"
|
2016-11-05 18:26:12 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// PlanGraphBuilder implements GraphBuilder and is responsible for building
|
|
|
|
// a graph for planning (creating a Terraform Diff).
|
|
|
|
//
|
|
|
|
// The primary difference between this graph and others:
|
|
|
|
//
|
|
|
|
// * Based on the config since it represents the target state
|
|
|
|
//
|
|
|
|
// * Ignores lifecycle options since no lifecycle events occur here. This
|
|
|
|
// simplifies the graph significantly since complex transforms such as
|
|
|
|
// create-before-destroy can be completely ignored.
|
|
|
|
//
|
|
|
|
type PlanGraphBuilder 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
|
|
|
// Config is the configuration tree to build a plan from.
|
|
|
|
Config *configs.Config
|
2016-11-05 18:26:12 -05:00
|
|
|
|
|
|
|
// State is the current state
|
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
|
|
|
State *states.State
|
2016-11-05 18:26:12 -05:00
|
|
|
|
2018-05-02 22:16:22 -05:00
|
|
|
// Components is a factory for the plug-in components (providers and
|
|
|
|
// provisioners) available for use.
|
|
|
|
Components contextComponentFactory
|
2017-01-25 14:24:48 -06:00
|
|
|
|
2018-05-31 14:39:45 -05:00
|
|
|
// Schemas is the repository of schemas we will draw from to analyse
|
|
|
|
// the configuration.
|
|
|
|
Schemas *Schemas
|
|
|
|
|
2016-11-07 16:09:11 -06:00
|
|
|
// Targets are resources to target
|
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
|
|
|
Targets []addrs.Targetable
|
2016-11-07 16:09:11 -06:00
|
|
|
|
2016-11-05 18:26:12 -05:00
|
|
|
// DisableReduce, if true, will not reduce the graph. Great for testing.
|
|
|
|
DisableReduce bool
|
2016-12-02 21:38:49 -06:00
|
|
|
|
|
|
|
// Validate will do structural validation of the graph.
|
|
|
|
Validate bool
|
2017-01-23 23:48:22 -06:00
|
|
|
|
2017-01-25 14:24:48 -06:00
|
|
|
// CustomConcrete can be set to customize the node types created
|
|
|
|
// for various parts of the plan. This is useful in order to customize
|
|
|
|
// the plan behavior.
|
|
|
|
CustomConcrete bool
|
|
|
|
ConcreteProvider ConcreteProviderNodeFunc
|
|
|
|
ConcreteResource ConcreteResourceNodeFunc
|
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
|
|
|
ConcreteResourceOrphan ConcreteResourceInstanceNodeFunc
|
2020-04-03 21:30:12 -05:00
|
|
|
ConcreteModule ConcreteModuleNodeFunc
|
2017-01-25 14:24:48 -06:00
|
|
|
|
|
|
|
once sync.Once
|
2016-11-05 18:26:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// See GraphBuilder
|
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 (b *PlanGraphBuilder) Build(path addrs.ModuleInstance) (*Graph, tfdiags.Diagnostics) {
|
2016-11-05 18:26:12 -05:00
|
|
|
return (&BasicGraphBuilder{
|
|
|
|
Steps: b.Steps(),
|
2016-12-02 21:38:49 -06:00
|
|
|
Validate: b.Validate,
|
2016-11-15 15:36:10 -06:00
|
|
|
Name: "PlanGraphBuilder",
|
2016-11-05 18:26:12 -05:00
|
|
|
}).Build(path)
|
|
|
|
}
|
|
|
|
|
|
|
|
// See GraphBuilder
|
|
|
|
func (b *PlanGraphBuilder) Steps() []GraphTransformer {
|
2017-01-25 14:24:48 -06:00
|
|
|
b.once.Do(b.init)
|
2016-11-07 10:57:27 -06:00
|
|
|
|
2018-09-20 14:30:52 -05:00
|
|
|
concreteResourceInstanceDeposed := func(a *NodeAbstractResourceInstance, key states.DeposedKey) dag.Vertex {
|
|
|
|
return &NodePlanDeposedResourceInstanceObject{
|
|
|
|
NodeAbstractResourceInstance: a,
|
2018-09-27 19:57:08 -05:00
|
|
|
DeposedKey: key,
|
2018-09-20 14:30:52 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-05 18:26:12 -05:00
|
|
|
steps := []GraphTransformer{
|
|
|
|
// Creates all the resources represented in the config
|
|
|
|
&ConfigTransformer{
|
2017-01-25 14:24:48 -06:00
|
|
|
Concrete: b.ConcreteResource,
|
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
|
|
|
Config: b.Config,
|
2016-11-05 18:26:12 -05:00
|
|
|
},
|
|
|
|
|
2017-07-01 11:48:37 -05:00
|
|
|
// Add the local values
|
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
|
|
|
&LocalTransformer{Config: b.Config},
|
2017-07-01 11:48:37 -05:00
|
|
|
|
2016-11-05 18:26:12 -05:00
|
|
|
// Add the outputs
|
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
|
|
|
&OutputTransformer{Config: b.Config},
|
2016-11-05 18:26:12 -05:00
|
|
|
|
2016-11-07 10:57:27 -06:00
|
|
|
// Add orphan resources
|
2018-09-26 17:26:39 -05:00
|
|
|
&OrphanResourceInstanceTransformer{
|
2017-01-25 14:24:48 -06:00
|
|
|
Concrete: b.ConcreteResourceOrphan,
|
2016-11-07 10:57:27 -06:00
|
|
|
State: b.State,
|
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
|
|
|
Config: b.Config,
|
2016-11-07 10:57:27 -06:00
|
|
|
},
|
|
|
|
|
2018-09-20 14:30:52 -05:00
|
|
|
// We also need nodes for any deposed instance objects present in the
|
|
|
|
// state, so we can plan to destroy them. (This intentionally
|
|
|
|
// skips creating nodes for _current_ objects, since ConfigTransformer
|
|
|
|
// created nodes that will do that during DynamicExpand.)
|
|
|
|
&StateTransformer{
|
|
|
|
ConcreteDeposed: concreteResourceInstanceDeposed,
|
|
|
|
State: b.State,
|
|
|
|
},
|
|
|
|
|
2017-11-08 10:11:26 -06:00
|
|
|
// Create orphan output nodes
|
|
|
|
&OrphanOutputTransformer{
|
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
|
|
|
Config: b.Config,
|
2017-11-08 10:11:26 -06:00
|
|
|
State: b.State,
|
|
|
|
},
|
|
|
|
|
2016-11-05 18:26:12 -05:00
|
|
|
// Attach the configuration to any resources
|
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
|
|
|
&AttachResourceConfigTransformer{Config: b.Config},
|
2016-11-05 18:26:12 -05:00
|
|
|
|
|
|
|
// Attach the state
|
|
|
|
&AttachStateTransformer{State: b.State},
|
|
|
|
|
2016-12-12 22:54:46 -06:00
|
|
|
// Add root variables
|
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
|
|
|
&RootVariableTransformer{Config: b.Config},
|
2016-12-12 22:54:46 -06:00
|
|
|
|
2018-05-02 22:16:22 -05:00
|
|
|
&MissingProvisionerTransformer{Provisioners: b.Components.ResourceProvisioners()},
|
2018-06-01 20:41:57 -05:00
|
|
|
&ProvisionerTransformer{},
|
2016-12-13 23:22:21 -06:00
|
|
|
|
2016-12-12 22:54:46 -06:00
|
|
|
// Add module variables
|
2017-07-21 11:41:29 -05:00
|
|
|
&ModuleVariableTransformer{
|
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
|
|
|
Config: b.Config,
|
2017-07-21 11:41:29 -05:00
|
|
|
},
|
2016-12-12 22:54:46 -06:00
|
|
|
|
2018-05-25 18:27:11 -05:00
|
|
|
TransformProviders(b.Components.ResourceProviders(), b.ConcreteProvider, b.Config),
|
|
|
|
|
2017-11-09 09:34:56 -06:00
|
|
|
// Remove modules no longer present in the config
|
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
|
|
|
&RemovedModuleTransformer{Config: b.Config, State: b.State},
|
2017-11-09 09:34:56 -06:00
|
|
|
|
2018-06-01 15:00:52 -05:00
|
|
|
// Must attach schemas before ReferenceTransformer so that we can
|
|
|
|
// analyze the configuration to find references.
|
2020-03-10 13:43:57 -05:00
|
|
|
&AttachSchemaTransformer{Schemas: b.Schemas, Config: b.Config},
|
2018-06-01 15:00:52 -05:00
|
|
|
|
2019-11-21 20:45:43 -06:00
|
|
|
// Create expansion nodes for all of the module calls. This must
|
|
|
|
// come after all other transformers that create nodes representing
|
|
|
|
// objects that can belong to modules.
|
2020-04-03 21:30:12 -05:00
|
|
|
&ModuleExpansionTransformer{
|
|
|
|
Concrete: b.ConcreteModule,
|
|
|
|
Config: b.Config,
|
|
|
|
},
|
2019-11-21 20:45:43 -06:00
|
|
|
|
2016-11-07 19:54:06 -06:00
|
|
|
// Connect so that the references are ready for targeting. We'll
|
|
|
|
// have to connect again later for providers and so on.
|
|
|
|
&ReferenceTransformer{},
|
|
|
|
|
2020-05-04 20:45:17 -05:00
|
|
|
// Make sure data sources are aware of any depends_on from the
|
|
|
|
// configuration
|
|
|
|
&AttachDependsOnTransformer{},
|
|
|
|
|
2017-04-20 00:23:52 -05:00
|
|
|
// Add the node to fix the state count boundaries
|
2018-08-27 14:03:20 -05:00
|
|
|
&CountBoundaryTransformer{
|
|
|
|
Config: b.Config,
|
|
|
|
},
|
2017-04-20 00:23:52 -05:00
|
|
|
|
2016-11-07 19:54:06 -06:00
|
|
|
// Target
|
core: -target option to also select resources in descendant modules
Previously the behavior for -target when given a module address was to
target only resources directly within that module, ignoring any resources
defined in child modules.
This behavior turned out to be counter-intuitive, since users expected
the -target address to be interpreted hierarchically.
We'll now use the new "Contains" function for addresses, which provides
a hierarchical "containment" concept that is more consistent with user
expectations. In particular, it allows module.foo to match
module.foo.module.bar.aws_instance.baz, where before that would not have
been true.
Since Contains isn't commutative (unlike Equals) this requires some
special handling for targeting specific indices. When given an argument
like -target=aws_instance.foo[0], the initial graph construction (for
both plan and refresh) is for the resource nodes from configuration, which
have not yet been expanded to separate indexed instances. Thus we need
to do the first pass of TargetsTransformer in mode where indices are
ignored, with the work then completed by the DynamicExpand method which
re-applies the TargetsTransformer in index-sensitive mode.
This is a breaking change for anyone depending on the previous behavior
of -target, since it will now select more resources than before. There is
no way provided to obtain the previous behavior. Eventually we may support
negative targeting, which could then combine with positive targets to
regain the previous behavior as an explicit choice.
2017-06-15 20:15:41 -05:00
|
|
|
&TargetsTransformer{
|
|
|
|
Targets: b.Targets,
|
|
|
|
|
|
|
|
// Resource nodes from config have not yet been expanded for
|
|
|
|
// "count", so we must apply targeting without indices. Exact
|
|
|
|
// targeting will be dealt with later when these resources
|
|
|
|
// DynamicExpand.
|
|
|
|
IgnoreIndices: true,
|
|
|
|
},
|
2016-11-07 19:54:06 -06:00
|
|
|
|
2018-09-21 19:08:52 -05:00
|
|
|
// Detect when create_before_destroy must be forced on for a particular
|
|
|
|
// node due to dependency edges, to avoid graph cycles during apply.
|
|
|
|
&ForcedCBDTransformer{},
|
|
|
|
|
2017-04-12 16:25:15 -05:00
|
|
|
// Close opened plugin connections
|
|
|
|
&CloseProviderTransformer{},
|
|
|
|
&CloseProvisionerTransformer{},
|
|
|
|
|
2020-04-02 14:49:32 -05:00
|
|
|
// Close the root module
|
|
|
|
&CloseRootModuleTransformer{},
|
2016-11-05 18:26:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if !b.DisableReduce {
|
|
|
|
// Perform the transitive reduction to make our graph a bit
|
|
|
|
// more sane if possible (it usually is possible).
|
|
|
|
steps = append(steps, &TransitiveReductionTransformer{})
|
|
|
|
}
|
|
|
|
|
|
|
|
return steps
|
|
|
|
}
|
2017-01-25 14:24:48 -06:00
|
|
|
|
|
|
|
func (b *PlanGraphBuilder) init() {
|
|
|
|
// Do nothing if the user requests customizing the fields
|
|
|
|
if b.CustomConcrete {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
b.ConcreteProvider = func(a *NodeAbstractProvider) dag.Vertex {
|
|
|
|
return &NodeApplyableProvider{
|
|
|
|
NodeAbstractProvider: a,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
b.ConcreteResource = func(a *NodeAbstractResource) dag.Vertex {
|
2020-03-20 14:19:01 -05:00
|
|
|
return &nodeExpandPlannableResource{
|
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: a,
|
2017-01-25 14:24:48 -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
|
|
|
b.ConcreteResourceOrphan = func(a *NodeAbstractResourceInstance) dag.Vertex {
|
|
|
|
return &NodePlannableResourceInstanceOrphan{
|
|
|
|
NodeAbstractResourceInstance: a,
|
2017-01-25 14:24:48 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|