Commit Graph

57 Commits

Author SHA1 Message Date
James Bardin
e6478599c6 strip unknown values from the resource config
Computed values are now all added to the config value as unknowns. Strip
these out to match the legacy expatiations.
2018-10-16 18:48:28 -07:00
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
Florian Forster
6680b1f16b core: check for negative indices in ResourceConfig.get
The bounds checking in ResourceConfig.get() was insufficient: it detected when the index was greater than or equal to cv.Len() but not when the index was less than zero. If the user provided an (invalid) configuration that referenced "foo.-1.bar", the provider would panic.

Now it behaves the same way as if the index were too high.
2017-12-12 09:18:38 -08:00
Martin Atkins
d4efc95191 command: show resource actions using resource addresses
Previously we were using the internal resource id syntax in the UI. Now
we'll use the standard user-facing resource address syntax instead.
2017-09-01 17:55:05 -07:00
James Bardin
68ba2d6ff0 ResourceConfig.get should never return (nil, true)
Fixes a case where ResourceConfig.get inadvertently returns a nil value.

Add an integration test where assigning a map to a list via
interpolation would panic.
2016-11-18 16:24:40 -05:00
Mitchell Hashimoto
9b5b122f14
terraform: ResourceConfig reimplementation for TypeUnknown
The primary change here is to expect that Config contains computed
values. This introduces `unknownCheckWalker` that does a really basic
reflectwalk to look for computed values and use that for IsComputed.

We had a weird mixture before checking whether c.Config was simply
missing values to determine where to look. Now we rely on IsComputed
heavily.
2016-11-09 14:28:16 -08:00
Mitchell Hashimoto
29485f6167
terraform: ResourceConfig.IsComputed cases 2016-11-09 14:28:15 -08:00
Mitchell Hashimoto
0c271b2b2d
terraform: better detection of unknown values in ResourceConfig, tests 2016-11-09 14:28:15 -08:00
Mitchell Hashimoto
9cc5e81a6c
terraform: add tests for IsComputed that pass on master 2016-11-09 14:28:15 -08:00
Mitchell Hashimoto
5ed1b5fc89
terraform: use the new TypeUnknown type from HIL
This makes all the computed stuff "just work" since HIL uses the same
computed sentinel value (string UUID) and the type differentiates it
from a regular string.
2016-11-09 14:28:15 -08:00
Mitchell Hashimoto
3dd64d9f2e
terraform: ResourceConfig.Equal should sort ComputedKeys
This was causing otherwise equal ResourceConfigs to report non-equal
which was incorrect, thus causing incorrect shadow graph errors.
2016-10-22 12:00:05 -07:00
Mitchell Hashimoto
77b9177bd5
terraform: an incredible number of failing tests! 2016-10-19 13:38:49 -07:00
Mitchell Hashimoto
d7a5cc5b35
terraform: InstanceInfo.uniqueId
This adds a new function to get a unique identifier scoped to the graph
walk in order to identify operations against the same instance. This is
used by the shadow to namespace provider function calls.
2016-10-11 22:17:30 +08:00
Mitchell Hashimoto
d37bb87bf2
terraform: ResourceConfig.DeepCopy should handle the nil case 2016-10-11 22:17:27 +08:00
Mitchell Hashimoto
37f5c6ae26
terraform: ResourceConfig.Equal handles nil case 2016-10-11 22:17:27 +08:00
Mitchell Hashimoto
f897fa4701
terraform: ResourceConfig.Equal and tests 2016-09-27 18:52:32 -07:00
Mitchell Hashimoto
56901e5cfd
terraform: ResourceConfig.DeepCopy
This implements DeepCopy, still need to implement Equals to make this
more useful. Coming in the next commit but this still has its own full
functionality + tests.
2016-09-27 16:09:32 -07:00
James Bardin
632c16c212 Fix inconsistent results with self interpolation
Due to a race in interpolateForce(), a reference to self could return
inconsistent results.
2016-08-30 14:16:37 -04:00
James Nugent
340655d56c core: Allow "." character in map keys
Fixes #2143 and fixes #7130.
2016-07-14 12:38:43 -06:00
Sander van Harmelen
d97b24e3c1
Add tests and fix last issues 2016-05-26 19:56:03 -05:00
Mitchell Hashimoto
fa934d96d0 helper/schema: FieldReaderConfig detects computed maps 2015-04-21 22:07:52 +02:00
Mitchell Hashimoto
0e59acc2c9 terraform: enable self vars 2015-02-23 14:56:02 -08:00
Mitchell Hashimoto
e37c187228 terraform: goodbye context.go (old) 2015-02-19 12:08:32 -08:00
Mitchell Hashimoto
012d68923c terraform: Eval 2015-02-19 12:07:55 -08:00
Mitchell Hashimoto
659a77c6ae helper/schema: validate subresources more effectively 2015-02-18 09:41:55 -08:00
Mitchell Hashimoto
dcaf653d6f helper/schema: properly detect that a list is computed 2014-10-09 19:09:06 -07:00
Mitchell Hashimoto
ea18b62e8f terraform: count.index 2014-10-02 22:02:59 -07:00
Armon Dadgar
4fe05428b3 terraform: Avoid having multiple primaries 2014-09-29 15:20:03 -07:00
Armon Dadgar
f398708be2 terraform: Adding flag for CreateBeforeDestroy 2014-09-29 15:20:03 -07:00
Mitchell Hashimoto
2791badf01 terraform: ask for input for providers 2014-09-29 09:13:15 -07:00
Mitchell Hashimoto
1835a03842 terraform: hook parameter is an InstanceInfo 2014-09-25 10:40:44 -07:00
Mitchell Hashimoto
d443202b31 terraform: fix copying dependencies 2014-09-23 14:20:26 -07:00
Mitchell Hashimoto
c164839ed1 terraform: walkContext 2014-09-23 13:21:45 -07:00
Mitchell Hashimoto
7a97396583 terraform: remove unused function 2014-09-21 22:35:11 -07:00
Mitchell Hashimoto
73e2a43427 terraform: don't put the ResourceState in Resource 2014-09-21 22:08:21 -07:00
Mitchell Hashimoto
13a4818867 terraform: add flags field 2014-09-20 17:02:31 -07:00
Mitchell Hashimoto
53c23266ca terraform: add Info field to Resource, remove from Node 2014-09-19 23:01:51 -06:00
Mitchell Hashimoto
f89c2c5ff0 terraform: graph tainted resources into the graph 2014-09-19 21:29:48 -06:00
Mitchell Hashimoto
9b2b3a963f ResourceDiff => InstanceDiff 2014-09-17 16:33:24 -07:00
Armon Dadgar
196991430b terraform: Resolving more errors 2014-09-16 14:26:27 -07:00
Mitchell Hashimoto
9ecfdc350e terraform: ResourceConfig.Get doesn't panic if exceed list bounds
[GH-210]
2014-08-21 11:37:14 -07:00
Mitchell Hashimoto
776b5ace2e terraform: better comments 2014-08-19 09:05:50 -07:00
Mitchell Hashimoto
d8a999e5af terraform: ResourceConfig.Get gets interpolated if possible 2014-08-19 09:05:19 -07:00
Mitchell Hashimoto
22e286ffd5 helper/schema: diff-ing lists at a basic level 2014-08-14 23:17:53 -07:00
Alex Gaynor
46154ca1d3 Fixed a ton of typos in docs and comments 2014-08-07 00:19:56 -07:00
Mitchell Hashimoto
78c32ac196 terraform: hooks around provisioners 2014-07-27 09:00:34 -07:00
Mitchell Hashimoto
14f7067b0c terraform: taint plan requires destroy/create 2014-07-22 10:30:42 -07:00
Armon Dadgar
94c95afa48 terraform: Passthrough provisioner level connection info 2014-07-15 12:34:06 -07:00
Armon Dadgar
8901a6753b terraform: Handle setup of providers in graph construction 2014-07-10 11:38:56 -07:00
Armon Dadgar
b2758666eb terraform: Store resource config along side provisioner 2014-07-10 11:38:55 -07:00