Commit Graph

22 Commits

Author SHA1 Message Date
Martin Atkins
c937c06a03 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-10-16 18:46:46 -07:00
James Bardin
b2d111c2bd return provisioner Apply errors
EvaApplyProvisioners was not returning errors if there was already a
multierror stored in the Error field. Always return the error to the
caller.
2018-03-15 16:04:05 -04:00
Martin Atkins
6712192724 core: don't advertise data source destroy via hooks
The fact that we clean up data source state by applying a "destroy" action
for them is an implementation detail, and so should not be visible to
outside callers or to the user.

Signalling these as real destroys creates confusion for users because
they see Terraform say things like:

    data.template_file.foo: Refreshing state..."

...which, to an understandably-nervous sysadmin, might make them suspect
that the underlying object was deleted, rather than just Terraform's
record of it.
2017-09-01 17:55:05 -07:00
Mitchell Hashimoto
d3df7874d5
terraform: introduce EvalApplyPre so that PreApply is called even for
destroy provisioners.
2017-01-20 20:36:53 -08:00
Mitchell Hashimoto
f40fdde708
terraform: PostProvision hook gets the error from the provision step 2017-01-20 20:21:12 -08:00
Mitchell Hashimoto
4a8c2d0958
terraform: on_failure for provisioners 2017-01-20 19:55:32 -08:00
Mitchell Hashimoto
85cb3a16b0
terraform: on destroy prov failure, don't taint and preserve state 2017-01-20 18:26:41 -08:00
Mitchell Hashimoto
e9f6c9c429
terraform: run destroy provisioners on destroy 2017-01-20 18:07:51 -08:00
James Bardin
475e0f1e6b Fix race on Provisioner.RawConfig
A race when accessing Provisioner.RawConfig can cause unexpected output
for provisioners that interpolate variables. Use RawConfig.Copy which
needs to acquire the RawConfig mutex to get the values.

Fixes #8890
2016-09-26 14:34:05 -04:00
James Bardin
5802f76eaa Make all terraform package tests pass under -race
This isn't a pretty refactor, but fixes the race issues in this package
for now.

Fix race on RawConfig.Config()

fix command package races
2016-07-29 16:12:21 -04:00
Sander van Harmelen
d97b24e3c1
Add tests and fix last issues 2016-05-26 19:56:03 -05:00
Panagiotis Moustafellos
e4845f75cc removed extra parentheses 2015-10-08 15:48:04 +03:00
Radek Simko
8e477b78d8 Add resource ID to errors coming from apply 2015-07-22 14:09:34 +02:00
Mitchell Hashimoto
b52881d232 terraform: clean up EvalNodes 2015-02-19 12:08:32 -08:00
Mitchell Hashimoto
b8ebcc85d7 terraform: partial state works properly 2015-02-19 12:08:07 -08:00
Mitchell Hashimoto
e2abf17c9c terraform: provisioners should only be run on first create 2015-02-19 12:08:06 -08:00
Mitchell Hashimoto
79746cb35d terraform: state must not be nil for apply 2015-02-19 12:08:06 -08:00
Mitchell Hashimoto
b8e5690565 terraform: eval post hook, eerrors 2015-02-19 12:08:06 -08:00
Mitchell Hashimoto
819aed67d4 terraform: provisioners 2015-02-19 12:08:06 -08:00
Mitchell Hashimoto
10e82375f2 terraform: early exit and cancellation 2015-02-19 12:08:05 -08:00
Mitchell Hashimoto
9b7d1509fc terraform: outputs in apply 2015-02-19 12:08:05 -08:00
Mitchell Hashimoto
a614f6105a terraform: apply starting 2015-02-19 12:08:04 -08:00