Commit Graph

1571 Commits

Author SHA1 Message Date
James Bardin 47b66a28b9 Merge pull request #10279 from hashicorp/jbardin/GH-9996
Set proper Mode when moving a data source in state
2016-11-22 08:49:25 -05:00
Mitchell Hashimoto f35d02cbee
terraform: test for alias inheritance [GH-4789] 2016-11-21 21:51:07 -08:00
Mitchell Hashimoto 71a1e215d9
terraform: add more Same test cases to cover #9171 2016-11-21 17:31:47 -08:00
James Bardin 705527e6fe Set proper Mode when moving a data source in state
ResourceAddr.Mode wasn't properly set when moving a module, so data
sources would lose the "data." prefix when their module was moved within
the State.
2016-11-21 18:26:29 -05:00
Mitchell Hashimoto b6687aa287
terraform: write lock on post state updates
Found race here: https://travis-ci.org/hashicorp/terraform/builds/177814212

Since WriteState calls `prune` and `init`, we're actually modifying the
state structure so we need a full write lock to perform this operation.
2016-11-21 15:21:35 -08:00
James Bardin c908f3ceae convert TestStateAdd to subtests 2016-11-21 18:13:15 -05:00
James Bardin 91378d0499 Merge pull request #10233 from hashicorp/jbardin/GH-10229
An empty module in state can panic
2016-11-21 17:35:33 -05:00
James Bardin e3ef8e6f8a Merge pull request #10228 from hashicorp/jbardin/map-crash
ResourceConfig.get should never return (nil, true)
2016-11-21 12:01:30 -05:00
James Bardin 8f6583c264 Add test for ResourceConfig.Get
ResourceConfig.Get could previously return (nil, true) when looking up
an interpolated map in a list because of the indexing ambiguity. Make
sure we test that a non-existent value always returns false.
2016-11-21 10:09:21 -05:00
James Bardin e045a9cc79 Merge pull request #10133 from hashicorp/jbardin/debug
DebugVisitInfo
2016-11-21 09:13:51 -05:00
James Bardin 5108182690 Merge pull request #10199 from hashicorp/jbardin/GH-10155
Catch map type errors on variable assignment
2016-11-21 09:13:16 -05:00
Mitchell Hashimoto e7d59ab245
terraform: test for interpolation escapes 2016-11-20 21:14:16 -08:00
James Bardin a5cb530571 Move the state module cleanup from init to prune
It makes for sense for this to happen in State.prune(). Also move a
redundant pruning from ResourceState.init, and make sure
ResourceState.prune is called from the parent's prune method.
2016-11-20 11:33:41 -05:00
James Bardin def55e52ca An empty module in state can panic
An empty module, or a module with an empty path can panic during graph
traversal. Make sure we clear these out when reading and writing the
state.
2016-11-18 17:59:07 -05: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
James Bardin e331f05870 Return an error for setting a non-map to a map
Setting variables happens before context validation, so it's possible
that the user could be trying to set an incorrect variable type to a
map. Return a useful error rather than panicking.
2016-11-17 11:10:43 -05:00
James Bardin 8f6811da0c Add failing test for GH-10155
Overriding a map variable with the incorrect type panics
2016-11-16 18:20:59 -05:00
Mitchell Hashimoto 06b95b3c00 release: clean up after v0.8.0-beta2 2016-11-16 17:14:31 +00:00
Mitchell Hashimoto 7e4385ea2f v0.8.0-beta2 2016-11-16 17:13:31 +00:00
James Bardin 3df3b99276 Make sure each GraphBuilder has a Name
Ensure that each instance of BasucGraphBuilder gets a name corresponding
to the Builder which created it. This allows us to differentiate the
graphs in the logs.
2016-11-15 16:40:10 -05:00
Mitchell Hashimoto b72ef90c2f Revert "[WIP] core: Log diff mismatch using spew instead of %#v" 2016-11-15 11:53:28 -08:00
Mitchell Hashimoto b20f43834b Merge pull request #9118 from hashicorp/spew-diff-mismatch
[WIP] core: Log diff mismatch using spew instead of %#v
2016-11-15 11:53:19 -08:00
Mitchell Hashimoto 55ef93f0f9
terraform: Diff.Same should understand that Destroy might go false 2016-11-15 11:26:42 -08:00
Mitchell Hashimoto c6fd938fb8
terraform: EvalInstanceInfo on data sources in new graph
This doesn't cause any practical issues as far as I'm aware (couldn't
get any test to fail), but caused shadow errors since it wasn't matching
the prior behavior.
2016-11-15 09:02:10 -08:00
Mitchell Hashimoto b6f5eb6371 Merge pull request #10134 from hashicorp/b-shadow-close
helper/shadow: Close for auto-closing all values
2016-11-15 08:54:42 -08:00
Mitchell Hashimoto 6557a3de18
helper/shadow: Close for auto-closing all values
Fixes #10122

The simple fix was that we forgot to close `ReadDataApply` for the
provider. But I've always felt that this section of the code was brittle
and I wanted to put in a more robust solution. The `shadow.Close` method
uses reflection to automatically close all values.
2016-11-15 08:54:26 -08:00
James Bardin bb137f4bfb Remove the dot graphs from the debug log,
and record the walk visits in the debug information.
2016-11-15 11:11:53 -05:00
James Bardin 23de57ddf3 Merge pull request #10104 from hashicorp/jbardin/debug
DebugOperation
2016-11-15 10:16:08 -05:00
Mitchell Hashimoto aaf1ad0532 Merge pull request #10093 from hashicorp/f-console
Add `terraform console` for REPL
2016-11-14 11:53:49 -08:00
Mitchell Hashimoto 25d19ef3d0 Merge pull request #10080 from hashicorp/f-tf-version
terraform: support version requirement in configuration
2016-11-14 11:53:30 -08:00
Mitchell Hashimoto df34fa88ce Merge pull request #10076 from hashicorp/f-depend-module
terraform: depends_on can reference entire modules
2016-11-14 11:53:12 -08:00
Mitchell Hashimoto e3a01ccfd8 Merge pull request #10072 from hashicorp/f-output-depends-on
terraform: output nodes can have `depends_on`
2016-11-14 11:52:18 -08:00
Mitchell Hashimoto aa5d16be79
terraform: shadow errors with UUID() must be ignored
People with `uuid()` usage in their configurations would receive shadow
errors every time on plan because the UUID would change.

This is hacky fix but I also believe correct: if a shadow error contains
uuid() then we ignore the shadow error completely. This feels wrong but
I'll explain why it is likely right:

The "right" feeling solution is to create deterministic random output
across graph runs. This would require using math/rand and seeding it
with the same value each run. However, this alone probably won't work
due to Terraform's parallelism and potential to call uuid() in different
orders. In addition to this, you can't seed crypto/rand and its unlikely
that we'll NEVER use crypto/rand in the future even if we switched
uuid() to use math/rand.

Therefore, the solution is simple: if there is no shadow error, no
problem. If there is a shadow error and it contains uuid(), then ignore
it.
2016-11-14 10:20:26 -08:00
James Bardin de0cb17a39 Add Graph.DebugOperation
The method marks the start of a set of operations on the Graph, with
extra information optionally provided in the second paramter. This
returns a function with a single End method to mark the end of the set
in the logs.

Refactor the existing graph Begin/End Operation calls to use this single
method. Remove the *string types in the marshal structs, these are
strictly informational and don't need to differentiate empty vs unset
strings.

Add calls to DebugOperation for each step while building the graph.
2016-11-14 12:47:51 -05:00
Mitchell Hashimoto 9205d25d38 Merge pull request #10068 from hashicorp/b-destroy-edge
terraform: destroy edge must include resources through outputs
2016-11-14 09:34:36 -08:00
Mitchell Hashimoto 9e8f311df1
terraform: fix typo 2016-11-14 09:34:21 -08:00
James Bardin 7e66df3290 Rename annotation methods
Change AnnotateVertex and AnnotateEdge to VertexDebugInfo EdgeDebugInfo
to avoid confusion between debug output and future graph annotations.
2016-11-14 11:06:52 -05:00
James Bardin 916d3522b1 Write debug info using Graph.AnnotateVertex 2016-11-14 08:52:18 -05:00
James Bardin 6f9744292a Replace DebugGraphs with the Graph's methods
Now that the Graph can serialize itself, and log transformations,
there's no need for DebugGraph
2016-11-14 08:52:18 -05:00
James Bardin 6f347ebb3a Remove dot package
Unify all dot functionality in the dag package
2016-11-14 08:50:34 -05:00
James Bardin 8a5d71b0ac Implement dag.GraphNodeDotter (temporarily)
To maintain the same output, the Graph.Dot implementation needs to be
aware of GraphNodeDotter. Copy the interface into the dag package, and
make the Dot marshaler aware of which nodes implemented the interface.
This way we can remove most of the remaining dot code from terraform.
2016-11-14 08:50:34 -05:00
James Bardin 7b774f771b implement dag.Subgrapher interface
This allows the dag package to detect subgraphs, even when impelemnted
by types from other packages
2016-11-14 08:50:34 -05:00
James Bardin 28d406c040 Provider a marshaler for dag.Graph
The dot format generation was done with a mix of code from the terraform
package and the dot package. Unify the dot generation code, and it into
the dag package.

Use an intermediate structure to allow a dag.Graph to marshal itself
directly. This structure will be ablt to marshal directly to JSON, or be
translated to dot format. This was we can record more information about
the graph in the debug logs, and provide a way to translate those logged
structures to dot, which is convenient for viewing the graphs.
2016-11-14 08:50:33 -05:00
Mitchell Hashimoto a633cdf95d
terraform: improve error messages to assist REPL 2016-11-13 23:17:04 -08:00
Mitchell Hashimoto 1a8fbdc428
terraform: update interpolation to be more flexible w/o config 2016-11-13 23:17:03 -08:00
Mitchell Hashimoto 2c467e0f74
terraform: verify version requirements from configuration 2016-11-12 16:50:26 -08:00
Mitchell Hashimoto 538302f143
terraform: resources nested within a module must also be depended on
For example: A => B => C (modules). If A depends on module B, then it
also must depend on everything in module C.
2016-11-12 15:38:28 -08:00
Mitchell Hashimoto bcfec4e24e
terraform: test that dependencies in the state are enough to maintain
order
2016-11-12 15:22:48 -08:00
Mitchell Hashimoto 22dd4303bc
terraform: tests for ReferenceMap for module paths 2016-11-12 08:24:09 -08:00
Mitchell Hashimoto 0b87ef82c3
terraform: depends_on can reference entire modules 2016-11-12 08:07:45 -08:00