Commit Graph

34 Commits

Author SHA1 Message Date
Mitchell Hashimoto 3878b8b093
config: Merge respects Terraform blocks, provider aliases, and more
Fixes #10715

`config.Merge` was not updated to support a number of new features. This
updates the codepath to merge various fields, including the `terraform`
block which was the issue in #10715.

The `Merge` API is called when an `_override` file is present to _merge_
configurations. Normally configurations are _appended_. Only an override
file triggers a _merge_.

I started working on a generic library to do this automatically awhile
back but never finished it. This might motivate me to do so. In the
interest of getting a fix out though, we'll continue the manual
approach.
2016-12-13 21:48:59 -08:00
Mitchell Hashimoto b979d8927e
config: use ast.TypeUnknown and don't remove computed values 2016-11-09 14:28:15 -08:00
Raphael Randschau e97785c899 terraform/core: typo in RawConfig documentation (#9714) 2016-10-29 16:18:56 +01:00
Mitchell Hashimoto fee0351c66
config: RawConfig merge should only set unknown keys non-nil if
non-empty
2016-10-19 15:21:09 -07:00
Mitchell Hashimoto 30596ca371
terraform: sanity test (passes, always passed) 2016-10-11 22:17:31 +08: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 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
James Nugent e57a399d71 core: Use native HIL maps instead of flatmaps
This changes the representation of maps in the interpolator from the
dotted flatmap form of a string variable named "var.variablename.key"
per map element to use native HIL maps instead.

This involves porting some of the interpolation functions in order to
keep the tests green, and adding support for map outputs.

There is one backwards incompatibility: as a result of an implementation
detail of maps, one could access an indexed map variable using the
syntax "${var.variablename.key}".

This is no longer possible - instead HIL native syntax -
"${var.variablename["key"]}" must be used. This was previously
documented, (though not heavily used) so it must be noted as a backward
compatibility issue for Terraform 0.7.
2016-05-10 14:49:13 -04:00
James Nugent a0cc7115b3 deps: Update call sites of hil.Eval from update
hil.Eval() now returns (hil.EvaluationResult, error) instead of (value,
type, error). This commit updates the call sites, but retains all
previous behaviour. Tests are also updated.
2016-04-18 16:37:12 -07:00
Paul Hinze 3f72837f4b core: Make copies when creating destroy nodes
Fixes an interpolation race that was occurring when a tainted destroy
node and a primary destroy node both tried to interpolate a computed
count in their config. Since they were sharing a pointer to the _same_
config, depending on how the race played out one of them could catch the
config uninterpolated and would then throw a syntax error.

The `Copy()` tree implemented for this fix can probably be used
elsewhere - basically we should copy the config whenever we drop nodes
into the graph - but for now I'm just applying it to the place that
fixes this bug.

Fixes #4982 - Includes a test covering that race condition.
2016-02-09 09:25:16 -06:00
Mitchell Hashimoto 5f3de02fa9 remove config/lang, use hashicorp/hil 2016-02-03 13:24:04 -05:00
Paul Hinze 0739cf2348 provider/template: fix race causing panic in template_file
The render code path in `template_file` was doing unsynchronized access
to a shared mapping of functions in `config.Func`.

This caused a race condition that was most often triggered when a
`template_file` had a `count` of more than one, and expressed itself as
a panic in the plugin followed by a cascade of "unexpected EOF" errors
through the plugin system.

Here, we simply turn the FuncMap from shared state into a generated
value, which avoids the race. We do more re-initialization of the data
structure, but the performance implications are minimal, and we can
always revisit with a perf pass later now that the race is fixed.
2016-01-15 16:34:46 -05:00
Paul Hinze b781c6c446 core: keys() and values() funcs for map variables
they work on maps with both keys and values that are string types, which
AFAICT are the only types of maps we have right now.

closes #1915
2015-06-02 16:49:51 -05:00
Mitchell Hashimoto 06beab6fd8 config: copy the key on Copy 2015-04-09 09:31:04 -07:00
Mitchell Hashimoto b201983304 terraform: copy RawConfigs 2015-04-09 09:21:38 -07:00
Mitchell Hashimoto 5e25dc54a7 config: if any var is computed, the entire interpolation is computed 2015-02-27 22:47:43 -08:00
Mitchell Hashimoto 0a68576746 config: add RawConfig.Merge 2015-02-19 12:07:59 -08:00
Mitchell Hashimoto 2abeb2d9ac config: use new API 2015-01-14 22:03:15 -08:00
Mitchell Hashimoto 8ae14f06b3 config: variables must be typed 2015-01-14 10:40:43 -08:00
Mitchell Hashimoto 4af4c9e16c config: add lookup function back 2015-01-13 12:06:04 -08:00
Mitchell Hashimoto 1ccad4d729 config: convert fucntions, put functions into Scope 2015-01-13 11:50:44 -08:00
Mitchell Hashimoto 740c25d4ea config: convert to config/lang 2015-01-13 10:27:57 -08:00
Mitchell Hashimoto dd14303022 config: validate that count is an int 2014-10-02 16:51:20 -07:00
Mitchell Hashimoto fa05b165ad config: fix gob encode/decode for raw config and keys 2014-10-02 13:42:36 -07:00
Mitchell Hashimoto 8e2315599f config: Count can be a string (for interpolation) 2014-10-02 11:14:50 -07:00
Mitchell Hashimoto f26a2700a1 fmt 2014-08-22 08:46:03 -07:00
Mitchell Hashimoto da2e221628 terraform: Interpolate if there are any interpolations [GH-159] 2014-08-21 15:05:56 -07:00
Mitchell Hashimoto cabc007ec4 config: get rid of the variable*Walkers, replace with more generic 2014-07-21 11:45:56 -07:00
Mitchell Hashimoto 9d2e83d56d config: Merge works properly 2014-07-20 17:17:03 -07:00
Mitchell Hashimoto d2001275dc terraform: initial Plan structure
This is REALLY heavy and would be really hard to maintain any sort
of compatibility with, but it is what we're going to do during dev
initially (if we don't ship with it) in order to just get stuff working.
2014-06-20 10:33:26 -07:00
Mitchell Hashimoto 69841c22e6 config: RawConfig.Config returns raw if no interpolate 2014-06-12 17:47:05 -07:00
Mitchell Hashimoto 6420e4bd81 config: reorder 2014-06-12 17:27:53 -07:00
Mitchell Hashimoto e445f8db38 config: RawConfig works, plus tests 2014-06-12 17:24:55 -07:00
Mitchell Hashimoto 1af5aee146 config: remove unknown variable elements from the config 2014-06-12 16:40:53 -07:00