Commit Graph

1796 Commits

Author SHA1 Message Date
James Bardin 78c2720a4c Merge pull request #13793 from paybyphone/data_source_plan_count_boundary
core: Add CountBoundaryTransformer to the plan graph builder
2017-04-27 11:22:57 -04:00
tombuildsstuff 74eec4fab5 release: clean up after v0.9.4 2017-04-26 12:45:27 +00:00
tombuildsstuff 277bbf65d1
v0.9.4 2017-04-26 12:35:28 +00:00
Martin Atkins b1763e262a Restore stringer-generated files back to new version
stringer has changed the boilerplate it generates in a recent version.
We'd previously updated to the new format but accientally rolled back
to the old while merging a long-running feature branch.

This restores us back to the new format again.
2017-04-21 14:49:18 -07:00
James Bardin f4a37ed19a Merge pull request #13854 from hashicorp/jbardin/testraces
fix a few races in the context tests
2017-04-21 13:23:12 -04:00
James Bardin ad1cef4227 fix a few races in the context tests
these were so infrequent that the race detector couldn't catch them
either, but on a heavily loaded CI host they occasionally fail.
2017-04-21 12:30:53 -04:00
Jasmin Gacic 61499cfcf0 Provider Oneandone (#13633)
* Terraform Provider 1&1

* Addressing pull request remarks

* Fixed imports

* Fixing remarks

* Test optimiziation
2017-04-21 17:19:10 +03:00
Chris Marchesi 744727a28a core: Trap warnings as well as errors on resourceNestedCount test 2017-04-20 07:31:44 -07:00
Chris Marchesi d41b806789 core: Restore CountBoundaryTransformer to apply, add/adjust tests
Moving the transformer wholesale looks like it broke some tests, with
some actually doing legit work in normalizing singular resources from a
foo.0 notation to just foo.

Adjusted the TestPlanGraphBuilder to account for the extra
meta.count-boundary nodes in the graph output now, as well as added
another context test that tests this case. It appears the issue happens
during validate, as this is where the state can be altered to a broken
state if things are not properly transformed in the plan graph.
2017-04-19 22:23:52 -07:00
Chris Marchesi 2802d319d2 core: Move CountBoundaryTransformer to the plan graph builder
This fixes interpolation issues on grandchild data sources that have
multiple instances (ie: counts). For example, baz depends on bar, which
depends on foo.

In this instance, after an initial TF run is done and state is saved,
the next refresh/plan is not properly transformed, and instead of the
graph/state coming through as data.x.bar.0, it comes through as
data.x.bar.  This breaks interpolations that rely on splat operators -
ie: data.x.bar.*.out.
2017-04-19 16:56:54 -07:00
Sander van Harmelen 3d0073e05c core: fix a crash by suggesting a different approach to solve #11170 (#13541)
* Revert #11245, #11321, #11498 and #11757

These PR’s are all related to issue #11170 for which I would like to propose a different solution then the one currently implemented.

* A different approach to solve #11170

This approach has (IMHO) a few advantages with regards to the solution currently implemented. I will elaborate on this in the PR.
2017-04-14 22:32:30 +02:00
James Bardin 928e60672f context Refresh and Apply sometimes return nil
The documentation for Refresh indicates that it will always return a
valid state, but that wasn't true in the case of a graph builder error.
While this same concept wasn't documented for Apply, it was still
assumed in the terraform apply code.

Since the helper testing framework relies on the absence of a state to
determine if it can call Destroy, the Context can't can't start
returning a state in all cases. Document this, and use the State method
to fetch the correct state value after Apply.

Add a nil check to the WriteState function, so that writing a nil state
is a noop.

Make sure to init before sorting the state, to make sure we're not
attempting to sort nil values. This isn't technically needed with the
current code, but it's just safer in general.
2017-04-14 14:56:10 -04:00
Sander van Harmelen 051582d32a Add the close provider and provisioner transformers (#13102) 2017-04-12 23:25:15 +02:00
Martin Atkins 381adca0af release: clean up after v0.9.3 2017-04-12 20:39:57 +00:00
Martin Atkins 1601af7a07
v0.9.3 2017-04-12 20:21:42 +00:00
James Bardin 7d4cceb787 Merge pull request #13502 from hashicorp/jbardin/dedupe-depends_on
Remove duplicate entries from resource Dependencies
2017-04-10 12:06:54 -04:00
Benjamin Lau ba09e7dc5a the invalid variable syntax error message was misleading. changed text a little bit (#11953) 2017-04-10 08:37:12 -05:00
James Bardin 3f49227b72 add state an context tests
Make sure duplicate depends_on entries are pruned from existing states
on read.

Make sure new state built from configs with multiple references to the
same resource only add it once to the Dependencies.
2017-04-08 15:37:15 -04:00
James Bardin bd983f6cba don't forget to test the simple things 2017-04-08 15:37:15 -04:00
James Bardin b45b6a5c20 remove duplicates in Dependencies
duplicate entries could end up in "depends_on" in the state, which could
possible lead to erroneous state comparisons. Remove them when walking
the graph, and remove existing duplicates when pruning the state.
2017-04-08 15:37:15 -04:00
Martin Atkins e4a5d36127 core: EvalVariableBlock to decode maps and slices more carefully
Previously this function was depending on the mapstructure behavior of
failing with an error when trying to decode a map into a list or
vice-versa, but mapstructure's WeakDecode behavior changed so that it
will go to greater lengths to coerce the given value to fit into the
target type, causing us to mis-handle certain ambigous cases.

Here we exert a bit more control over what's going on by using 'reflect'
to first check whether we have a slice or map value and only then try
to decode into one with mapstructure. This allows us to still rely on
mapstructure's ability to decode nested structures but ensure that lists
and maps never get implicitly converted to each other.
2017-04-07 17:05:14 -07:00
Martin Atkins 0e963db2c5 Detect and reject unknown attributes in "connection" blocks
Since the validation of connection blocks is delegated to the communicator
selected by "type", we were not previously doing any validation of the
attribute names in these blocks until running provisioners during apply.

Proper validation here requires us to already have the instance state,
since the final connection info is a merge of values provided in config
with values assigned automatically by the resource. However, we can do
some basic name validation to catch typos during the validation pass, even
though semantic validation and checking for missing attributes will still
wait until the provisioner is instantiated.

This fixes #6582 as much as we reasonably can.
2017-04-06 13:46:43 -07:00
Martin Atkins 28d6d913e4 core: basic test of EvalVariableBlock
This previously lacked tests altogether. This new test verifies the
"happy path", ensuring that both literal and computed values pass through
correctly into the VariableValues map.
2017-04-04 12:16:19 -07:00
Martin Atkins c1c5c9a2f6 core: fix crash when computed nested map given in module block
This crash resulted because the type switch checked for either of two
types but the type assertion within it assumed only one of them.

A straightforward (if inelegant) fix is to simply duplicate the relevant
case block and change the type assertion, thus allowing the types to match
up in all cases.

This fixes #13297.
2017-04-04 12:16:19 -07:00
Martin Atkins dd8af65c82 core: Input walk shouldn't clobber dynamic provider config
During the input walk we stash the values resulting from user input
(if any) in the eval context for use when later walks need to resolve
the provider config.

However, this repository of input results is only able to represent
literal values, since it does not retain the record of which of the keys
have values that are "computed".

Previously we were blindly stashing all of the results, failing to
consider that some of them might be computed. That resulted in the
UnknownValue placeholder being misinterpreted as a literal value when
the data is used later, which ultimately resulted in it clobbering the
actual expression evaluation result and thus causing the provider to
fail to configure itself.

Now we are careful to only retain in this repository the keys whose values
are known statically during the input phase. This eventually gets merged
with the dynamic evaluation results on subsequent walks, with the dynamic
keys left untouched due to their absence from the stored input map.

This fixes #11264.
2017-04-04 10:31:42 -07:00
James Bardin c55a5082f5 delegate BackendState.Rehash to config.Backend 2017-03-29 18:01:03 -04:00
James Bardin ff2d753062 add Rehash to terraform.BackendState
This method mirrors that of config.Backend, so we can compare the
configration of a backend read from a config vs that of a backend read
from a state. This will prevent init from reinitializing when using
`-backend-config` options that match the existing state.
2017-03-29 15:53:42 -04:00
Martin Atkins 21cd5595e2 Update stringer-generated files to new boilerplate
golang/tools commit 23ca8a263 changed the format of the leading comment
to comply with some new standards discussed here:
https://golang.org/issue/13560

This is the result of running generate with the latest version of
stringer. Everyone working on Terraform will need to update stringer
after this is merged, to avoid reverting this:
    go get -u golang.org/x/tools/cmd/stringer
2017-03-29 08:07:06 -07:00
Paul Stack 7479b8d150 release: clean up after v0.9.2 2017-03-28 10:05:25 +00:00
Paul Stack 6365269541
v0.9.2 2017-03-28 09:56:35 +00:00
Mitchell Hashimoto 69759e04ca
terraform: convert empty path to root path in V1 state 2017-03-21 11:37:12 -07:00
Mitchell Hashimoto e7b07e109f
terraform: V1 to V2 upgrade should treat nil path as root path
It appears there are no tests for this as far as I can find.

We change V1 states (very old) to assume a nil path is a root path.
Staet.Validate() later will catch any duplicate paths.
2017-03-21 11:12:44 -07:00
James Bardin b7152c4405 Merge pull request #12897 from hashicorp/jbardin/ignore-changes
ignore_changes causes keys in other flatmapped objects to be lost from diff
2017-03-21 09:25:47 -04:00
James Bardin 0ae0076e3a Correctly filter flatmapped values in diff
When transforming a diff from DestroyCreate to a simple Update,
ignore_changes can cause keys from flatmapped objects to be filtered
form the diff. We need to filter each flatmapped container as a whole to
ensure that unchanged keys aren't lost in the update.
2017-03-21 09:11:54 -04:00
James Bardin 3001f0c1b9 Fix test that relied on empty Old diff 2017-03-20 17:44:38 -04:00
James Bardin 970e7c1923 Add a failing test for missing keys in diff
ignore_changes is causing changes in other flatmapped sets to be
filtered out incorrectly.

This required fixing the testDiffFn to create diffs which include the
old value, breaking one other test.
2017-03-20 17:44:37 -04:00
Benjamin Boudreau 073fa873ac Fix receive typo (#12881) 2017-03-20 13:15:27 -04:00
Mitchell Hashimoto 1d1dc7cf30 release: clean up after v0.9.1 2017-03-17 22:54:23 +00:00
Mitchell Hashimoto 7c25ef851b
v0.9.1 2017-03-17 22:48:44 +00:00
Mitchell Hashimoto e8b3062629
terraform: unknown value for variables not set
Fixes #12836

Realistically, these should be caught during validation anyways. In this
case, this was causing 12386 because refresh with a data source will
attempt to use module variables. I don't see any clear logic to prune
those module variables or not add them so its easier to return unknown
to cause the data to be computed and not run.
2017-03-17 15:33:33 -07:00
James Bardin 9e8ddaed47 Don't interpolate multivariables during walkInput
We don't need these expanded for input, and if the multivar's count is a
variable, it may be known but not available during the input walk.
2017-03-16 13:45:07 -04:00
James Bardin fe5f519817 Add failing test for invalid interpolation
Adding the submodule causes the count variable interpolation to fail.
2017-03-16 10:35:18 -04:00
Mitchell Hashimoto 37b3fe1119 release: clean up after v0.9.0 2017-03-15 16:39:53 +00:00
Mitchell Hashimoto 5bd194faa6
v0.9.0 2017-03-15 16:33:13 +00:00
James Bardin 7c9863ccb0 fix another hot lop in tests
Found another test spinlock.
Slow it down to prevent it from blocking the runtime scheduler.
2017-03-15 12:02:28 -04:00
Mitchell Hashimoto 9900bd752a
terraform: string through the context meta 2017-03-13 16:21:09 -07:00
Mitchell Hashimoto 4e1511c77f
terraform: interpolate "terraform.env" 2017-03-13 16:14:27 -07:00
James Bardin ecb1944c31 Merge pull request #12498 from hashicorp/jbardin/test-reset
Add schema.Provider.TestReset to reset StopContext between tests
2017-03-09 08:34:54 -05:00
James Bardin 5238f51dc7 move TestReset mock from terraform to helper
the terraform package doesn't know about TestProvider, so don't put the
hooks in terraform.MockResourceProvider. Wrap the mock in the test where
we need to check the TestProvider functionality.
2017-03-08 17:48:11 -05:00
James Bardin 38d2a8f6ac Fix logic race with Context.watchStop
Always wait for watchStop to return during context.walk.

Context.walk would often complete immediately after sending the close
signal to watchStop, which would in turn call the deferred releaseRun
cancelling the runContext.

Without any synchronization points after the select statement in
watchStop, that goroutine was not guaranteed to be scheduled
immediately, and in fact it often didn't continue until after the
runContext was canceled. This in turn left the select statement with
multiple successful cases, and half the time it would chose to Stop the
providers.

Stopping the providers after the walk of course didn't cause any
immediate failures, but if there was another walk performed, the
provider StopContext would no longer be valid and could cause
cancellation errors in the provider.
2017-03-08 15:11:10 -05:00