Commit Graph

23 Commits

Author SHA1 Message Date
Mitchell Hashimoto 68ee4e0480
config/module: don't panic when referencing undefined module
Fixes #12788

We would panic when referencing an output from an undefined module. The
panic above this is correct but in this case Load will not catch
interpolated variables that _reference_ an unloaded/undefined module.
Test included.
2017-03-16 20:14:20 -07:00
James Bardin 2a949093ed report all errors from module validation
It can be tedious fixing a new module with many errors when Terraform
only outputs the first random error it encounters.

Accumulate all errors from validation, and format them for the user.
2017-03-02 15:16:05 -05:00
Mitchell Hashimoto 095b7e7831
config/module: disallow root modules named "root"
Fixes #11038

This is a **short term fix**.

Terraform core doesn't currently handle root modules named "root" well
because the prefix `[]string{"root"}` has special meaning and Terraform
core [currently] can't disambiguate between the root module and a module
named "root" in the root module.

This PR introduces a short term fix by simply disallowing root modules
named "root". This shouldn't break any BC because since 0.8.0 this
didn't work at all in many broken ways (including crashes).

Longer term, this should be fixed by removing the special prefix at all
and having empty paths be root. I started down this path but the core
changes necessary are far too scary for a patch release. We can aim for
0.9.
2017-01-08 15:39:57 -08:00
Mitchell Hashimoto 0c30caec7d
config: smarter provider alias usage validation
Fixes #4789

This improves the validation that valid provider aliases are used.

Previously, we required that provider aliases be defined in every module
they're used. This isn't correct because the alias may be used in a
parent module and inherited.

This removes that validation and creates the validation that a provider
alias must be defined in the used module or _any parent_. This allows
inheritance to work properly.

We've always had this type of validation for aliases because we believe
its a good UX tradeoff: typo-ing an alias is really painful, so we
require declaration of alias usage. It may add a small burden to
declare, but since relatively few aliases are used, it improves the
scenario where a user fat-fingers an alias name.
2016-12-16 16:47:32 -08:00
Mitchell Hashimoto 55ef966b88
config/module: tree.Child on a nil tree works 2016-10-19 13:38:49 -07:00
Mitchell Hashimoto 098225dc0d
config/module: use the raw source as part of the key
This changes the key for the storage to be the _raw_ source from the
module, not the fully expanded source. Example: it'll be a relative path
instead of an absolute path.

This allows the ".terraform/modules" directory to be portable when
moving to other machines. This was a behavior that existed in <= 0.7.2
and was broken with #8398. This amends that and adds a test to verify.
2016-09-30 10:44:46 -07:00
Mitchell Hashimoto 1099e3f59f config: add module raw configs to InterpolatedConfigs [GH-1448] 2015-04-29 17:12:28 -07:00
Mitchell Hashimoto f084d8d932 config/module: store the path with the module 2015-04-07 16:37:46 -07:00
Mitchell Hashimoto 2e11ca68df config/module: go back to the original folder when doing parent
references
2015-03-26 09:30:32 -07:00
Mitchell Hashimoto bd4aaac71a config/module: failing unit test for GH-1232 2015-03-26 09:11:32 -07:00
Mitchell Hashimoto 1e00b4386c config/module: Child(nil) or empty will return self 2014-10-07 20:02:18 -07:00
Mitchell Hashimoto 267d45df86 config/module: Can look up Child with Tree.Child 2014-10-07 20:00:36 -07:00
Mitchell Hashimoto 7aa30fdf25 config: support subdirectories with the "//" syntax 2014-09-26 14:56:04 -07:00
Mitchell Hashimoto 1ef167602e config/module: validate that required parameters are passed through 2014-09-24 19:40:06 -07:00
Mitchell Hashimoto 97da02c368 config/module: proper name for root 2014-09-22 16:39:01 -07:00
Mitchell Hashimoto 7bbf6a0d3a config/module: NewTreeModule is easier to use 2014-09-15 15:49:07 -07:00
Mitchell Hashimoto 292f57ea0a config/module: validate outputs line up with ModuleVariables 2014-09-15 13:57:07 -07:00
Mitchell Hashimoto 12e7c75211 config/module: validate that parameters into modules valid 2014-09-15 10:32:41 -07:00
Mitchell Hashimoto 2419bf79f2 config/module: error if duplicate module 2014-09-15 09:53:29 -07:00
Mitchell Hashimoto c9fd910c41 config/module: Validate 2014-09-15 09:37:40 -07:00
Mitchell Hashimoto 30b76ef820 config/module: tree.String() 2014-09-14 20:14:37 -07:00
Mitchell Hashimoto a35a9262d4 config/module: detectors, some more work on Tree 2014-09-14 16:17:29 -07:00
Mitchell Hashimoto 799ffbb3ac config/module: tree.Modules() 2014-09-14 14:46:45 -07:00