Skip to content

Commit

Permalink
Merge pull request #1744 from hashicorp/b-module-output-validate
Browse files Browse the repository at this point in the history
config: add module raw configs to InterpolatedConfigs [GH-1448]
  • Loading branch information
mitchellh committed Apr 30, 2015
2 parents 430e00c + 1099e3f commit 12a088f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
variable "memory" { default = "foo" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module "child" {
source = "./child"
}

module "child2" {
source = "./child"
memory = "${module.child.memory_max}"
}
12 changes: 12 additions & 0 deletions config/module/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))

Expand Down

0 comments on commit 12a088f

Please sign in to comment.