2016-09-13 12:56:37 -05:00
|
|
|
package terraform
|
|
|
|
|
|
|
|
import (
|
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-09-21 16:30:41 -05: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-09-13 12:56:37 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// ApplyGraphBuilder implements GraphBuilder and is responsible for building
|
|
|
|
// a graph for applying a Terraform diff.
|
|
|
|
//
|
|
|
|
// Because the graph is built from the diff (vs. the config or state),
|
|
|
|
// this helps ensure that the apply-time graph doesn't modify any resources
|
|
|
|
// that aren't explicitly in the diff. There are other scenarios where the
|
|
|
|
// diff can be deviated, so this is just one layer of protection.
|
|
|
|
type ApplyGraphBuilder 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 that the diff was built from.
|
|
|
|
Config *configs.Config
|
2016-09-13 12:56:37 -05:00
|
|
|
|
|
|
|
// Diff is the diff to apply.
|
|
|
|
Diff *Diff
|
|
|
|
|
2016-09-13 19:52:09 -05:00
|
|
|
// State is the current state
|
|
|
|
State *State
|
|
|
|
|
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
|
2016-09-22 13:03:03 -05:00
|
|
|
|
2017-02-13 14:52:45 -06:00
|
|
|
// Targets are resources to target. This is only required to make sure
|
|
|
|
// unnecessary outputs aren't included in the apply graph. The plan
|
|
|
|
// builder successfully handles targeting resources. In the future,
|
|
|
|
// outputs should go into the diff so that this is unnecessary.
|
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
|
2017-02-13 14:52:45 -06:00
|
|
|
|
2016-09-22 13:03:03 -05:00
|
|
|
// DisableReduce, if true, will not reduce the graph. Great for testing.
|
|
|
|
DisableReduce bool
|
2016-10-21 01:22:33 -05:00
|
|
|
|
|
|
|
// Destroy, if true, represents a pure destroy operation
|
|
|
|
Destroy bool
|
2016-12-02 21:38:49 -06:00
|
|
|
|
|
|
|
// Validate will do structural validation of the graph.
|
|
|
|
Validate bool
|
2016-09-13 12:56:37 -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 *ApplyGraphBuilder) Build(path addrs.ModuleInstance) (*Graph, tfdiags.Diagnostics) {
|
2016-09-13 12:56:37 -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: "ApplyGraphBuilder",
|
2016-09-13 12:56:37 -05:00
|
|
|
}).Build(path)
|
|
|
|
}
|
|
|
|
|
|
|
|
// See GraphBuilder
|
|
|
|
func (b *ApplyGraphBuilder) Steps() []GraphTransformer {
|
2016-09-15 01:58:16 -05:00
|
|
|
// Custom factory for creating providers.
|
2016-12-03 17:27:38 -06:00
|
|
|
concreteProvider := func(a *NodeAbstractProvider) dag.Vertex {
|
2016-09-15 01:58:16 -05:00
|
|
|
return &NodeApplyableProvider{
|
2016-12-03 17:27:38 -06:00
|
|
|
NodeAbstractProvider: a,
|
2016-09-15 01:58:16 -05: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
|
|
|
concreteResource := func(a *NodeAbstractResourceInstance) dag.Vertex {
|
|
|
|
return &NodeApplyableResourceInstance{
|
|
|
|
NodeAbstractResourceInstance: a,
|
2016-09-21 16:30:41 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-13 12:56:37 -05:00
|
|
|
steps := []GraphTransformer{
|
|
|
|
// Creates all the nodes represented in the diff.
|
2016-09-13 19:52:09 -05:00
|
|
|
&DiffTransformer{
|
2016-09-21 16:30:41 -05:00
|
|
|
Concrete: 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
|
|
|
Diff: b.Diff,
|
2016-09-13 19:52:09 -05:00
|
|
|
},
|
2016-09-13 16:34:15 -05:00
|
|
|
|
2016-09-18 23:45:19 -05:00
|
|
|
// Create orphan output nodes
|
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
|
|
|
&OrphanOutputTransformer{Config: b.Config, State: b.State},
|
2016-09-18 23:45:19 -05:00
|
|
|
|
2016-09-20 12:23:48 -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-09-20 12:23:48 -05:00
|
|
|
|
2016-09-16 22:26:10 -05:00
|
|
|
// Attach the state
|
|
|
|
&AttachStateTransformer{State: b.State},
|
|
|
|
|
2017-11-02 09:02:51 -05:00
|
|
|
// add providers
|
2018-05-02 22:16:22 -05:00
|
|
|
TransformProviders(b.Components.ResourceProviders(), concreteProvider, b.Config),
|
2016-09-13 19:11:34 -05:00
|
|
|
|
2016-12-10 19:11:24 -06:00
|
|
|
// Destruction ordering
|
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
|
|
|
&DestroyEdgeTransformer{Config: b.Config, State: b.State},
|
2016-12-10 19:11:24 -06:00
|
|
|
GraphTransformIf(
|
|
|
|
func() bool { return !b.Destroy },
|
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
|
|
|
&CBDEdgeTransformer{Config: b.Config, State: b.State},
|
2016-12-10 19:11:24 -06:00
|
|
|
),
|
|
|
|
|
2016-09-15 11:32:37 -05:00
|
|
|
// Provisioner-related transformations
|
2018-05-02 22:16:22 -05:00
|
|
|
&MissingProvisionerTransformer{Provisioners: b.Components.ResourceProvisioners()},
|
2017-01-20 20:07:51 -06:00
|
|
|
&ProvisionerTransformer{},
|
2016-09-15 11:32:37 -05:00
|
|
|
|
2016-09-16 16:36:35 -05: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-09-16 16:36:35 -05:00
|
|
|
|
2017-07-01 13:08:15 -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 13:08:15 -05:00
|
|
|
|
2016-09-16 01:20:35 -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-09-16 01:20:35 -05:00
|
|
|
|
2016-11-04 20:58:03 -05:00
|
|
|
// Add module 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
|
|
|
&ModuleVariableTransformer{Config: b.Config},
|
2016-11-04 20:58:03 -05:00
|
|
|
|
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-05-02 22:16:22 -05:00
|
|
|
// Must be before ReferenceTransformer, since schema is required to
|
|
|
|
// extract references from config.
|
|
|
|
&AttachSchemaTransformer{Components: b.Components},
|
|
|
|
|
2016-09-15 20:30:11 -05:00
|
|
|
// Connect references so ordering is correct
|
|
|
|
&ReferenceTransformer{},
|
|
|
|
|
2018-01-30 09:24:15 -06:00
|
|
|
// Handle destroy time transformations for output and local values.
|
2018-01-29 15:16:41 -06:00
|
|
|
// Reverse the edges from outputs and locals, so that
|
2017-09-29 10:12:57 -05:00
|
|
|
// interpolations don't fail during destroy.
|
2018-01-30 09:24:15 -06:00
|
|
|
// Create a destroy node for outputs to remove them from the state.
|
|
|
|
// Prune unreferenced values, which may have interpolations that can't
|
|
|
|
// be resolved.
|
2017-09-29 10:12:57 -05:00
|
|
|
GraphTransformIf(
|
|
|
|
func() bool { return b.Destroy },
|
2018-01-30 09:24:15 -06:00
|
|
|
GraphTransformMulti(
|
|
|
|
&DestroyValueReferenceTransformer{},
|
|
|
|
&DestroyOutputTransformer{},
|
|
|
|
&PruneUnusedValuesTransformer{},
|
|
|
|
),
|
2018-01-29 18:17:31 -06:00
|
|
|
),
|
|
|
|
|
2016-09-19 11:28:24 -05:00
|
|
|
// Add the node to fix the state count boundaries
|
|
|
|
&CountBoundaryTransformer{},
|
|
|
|
|
2017-02-13 14:52:45 -06:00
|
|
|
// Target
|
|
|
|
&TargetsTransformer{Targets: b.Targets},
|
|
|
|
|
2017-04-12 16:25:15 -05:00
|
|
|
// Close opened plugin connections
|
|
|
|
&CloseProviderTransformer{},
|
|
|
|
&CloseProvisionerTransformer{},
|
|
|
|
|
2016-09-13 16:34:15 -05:00
|
|
|
// Single root
|
|
|
|
&RootTransformer{},
|
2016-09-22 13:03:03 -05:00
|
|
|
}
|
2016-09-19 11:28:24 -05:00
|
|
|
|
2016-09-22 13:03:03 -05:00
|
|
|
if !b.DisableReduce {
|
2016-09-19 11:28:24 -05:00
|
|
|
// Perform the transitive reduction to make our graph a bit
|
|
|
|
// more sane if possible (it usually is possible).
|
2016-09-22 13:03:03 -05:00
|
|
|
steps = append(steps, &TransitiveReductionTransformer{})
|
2016-09-13 12:56:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return steps
|
|
|
|
}
|