config: add module raw configs to InterpolatedConfigs [GH-1448]

This commit is contained in:
Mitchell Hashimoto 2015-04-29 17:12:28 -07:00
parent 31716cee27
commit 1099e3f59f
4 changed files with 26 additions and 0 deletions

View File

@ -570,6 +570,11 @@ func (c *Config) InterpolatedVariables() map[string][]InterpolatedVariable {
// a human-friendly source.
func (c *Config) rawConfigs() map[string]*RawConfig {
result := make(map[string]*RawConfig)
for _, m := range c.Modules {
source := fmt.Sprintf("module '%s'", m.Name)
result[source] = m.RawConfig
}
for _, pc := range c.ProviderConfigs {
source := fmt.Sprintf("provider config '%s'", pc.Name)
result[source] = pc.RawConfig

View File

@ -0,0 +1 @@
variable "memory" { default = "foo" }

View File

@ -0,0 +1,8 @@
module "child" {
source = "./child"
}
module "child2" {
source = "./child"
memory = "${module.child.memory_max}"
}

View File

@ -224,6 +224,18 @@ func TestTreeValidate_badChildOutput(t *testing.T) {
}
}
func TestTreeValidate_badChildOutputToModule(t *testing.T) {
tree := NewTree("", testConfig(t, "validate-bad-output-to-module"))
if err := tree.Load(testStorage(t), GetModeGet); err != nil {
t.Fatalf("err: %s", err)
}
if err := tree.Validate(); err == nil {
t.Fatal("should error")
}
}
func TestTreeValidate_badChildVar(t *testing.T) {
tree := NewTree("", testConfig(t, "validate-bad-var"))