Merge pull request #1744 from hashicorp/b-module-output-validate

config: add module raw configs to InterpolatedConfigs [GH-1448]
This commit is contained in:
Mitchell Hashimoto 2015-04-30 14:36:33 -07:00
commit 12a088f6c5
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. // a human-friendly source.
func (c *Config) rawConfigs() map[string]*RawConfig { func (c *Config) rawConfigs() map[string]*RawConfig {
result := make(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 { for _, pc := range c.ProviderConfigs {
source := fmt.Sprintf("provider config '%s'", pc.Name) source := fmt.Sprintf("provider config '%s'", pc.Name)
result[source] = pc.RawConfig 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) { func TestTreeValidate_badChildVar(t *testing.T) {
tree := NewTree("", testConfig(t, "validate-bad-var")) tree := NewTree("", testConfig(t, "validate-bad-var"))